zhaozhao.zz
f20408777a
networking: fix unexpected negative or zero readlen
...
To avoid copying buffers to create a large Redis Object which
exceeding PROTO_IOBUF_LEN 32KB, we just read the remaining data
we need, which may less than PROTO_IOBUF_LEN. But the remaining
len may be zero, if the bulklen+2 equals sdslen(c->querybuf),
in client pause context.
For example:
Time1:
python
>>> import os, socket
>>> server="127.0.0.1"
>>> port=6379
>>> data1="*3\r\n$3\r\nset\r\n$1\r\na\r\n$33000\r\n"
>>> data2="".join("x" for _ in range(33000)) + "\r\n"
>>> data3="\n\n"
>>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>> s.settimeout(10)
>>> s.connect((server, port))
>>> s.send(data1)
28
Time2:
redis-cli client pause 10000
Time3:
>>> s.send(data2)
33002
>>> s.send(data3)
2
>>> s.send(data3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
socket.error: [Errno 104] Connection reset by peer
To fix that, we should check if remaining is greater than zero.
2018-08-31 20:02:09 +08:00
..
2018-07-03 18:19:46 +02:00
2017-11-28 18:25:14 +01:00
2017-05-02 15:05:39 +02:00
2016-04-25 16:49:57 +03:00
2014-06-26 18:48:40 +02:00
2016-06-07 16:46:00 -04:00
2018-07-04 20:04:06 +08:00
2018-03-28 14:11:04 +02:00
2018-03-21 15:34:13 +08:00
2016-04-04 08:50:58 +02:00
2018-08-03 12:46:06 +02:00
2018-07-03 18:19:46 +02:00
2018-03-16 00:44:50 +08:00
2015-10-01 13:02:25 +02:00
2018-07-03 18:19:46 +02:00
2018-08-14 20:59:32 +08:00
2016-09-19 14:11:17 +02:00
2018-07-31 17:13:03 +02:00
2018-07-03 18:19:46 +02:00
2018-08-27 12:27:17 +02:00
2018-03-16 00:44:50 +08:00
2015-07-26 15:17:18 +02:00
2014-12-23 09:31:03 -05:00
2014-12-23 09:31:03 -05:00
2018-07-31 12:07:57 +08:00
2018-07-30 12:23:51 +03:00
2016-08-04 15:12:12 +08:00
2018-07-18 10:16:33 +03:00
2018-07-17 10:39:47 +02:00
2017-12-05 15:38:03 +01:00
2014-12-23 09:31:03 -05:00
2018-07-03 18:19:46 +02:00
2018-08-27 12:20:27 +02:00
2018-06-21 22:08:09 +08:00
2014-12-05 12:41:59 +11:00
2018-07-03 18:19:46 +02:00
2015-07-26 15:17:18 +02:00
2017-07-03 19:38:31 +02:00
2016-07-06 16:31:11 +02:00
2018-06-12 15:28:28 +08:00
2016-07-27 11:34:25 +02:00
2018-06-27 16:33:31 +03:00
2018-07-03 18:19:46 +02:00
2016-12-20 15:39:56 +01:00
2016-06-20 23:08:06 +03:00
2018-07-13 17:53:55 +08:00
2015-02-11 10:52:27 +01:00
2018-07-31 12:07:57 +08:00
2017-12-01 10:24:24 +01:00
2018-07-03 18:19:46 +02:00
2017-12-01 10:24:24 +01:00
2018-07-13 09:46:30 -06:00
2015-01-02 11:16:10 -05:00
2018-06-03 15:54:30 +03:00
2014-06-26 18:48:40 +02:00
2017-11-19 16:23:42 +00:00
2018-07-04 16:50:22 +02:00
2015-12-16 17:41:22 +01:00
2016-04-29 16:45:53 +01:00
2018-07-30 16:18:56 +03:00
2017-07-12 11:07:28 +02:00
2018-08-31 20:02:09 +08:00
2018-07-17 18:04:55 +02:00
2018-07-23 18:44:58 +02:00
2014-06-26 18:48:40 +02:00
2018-07-02 18:49:34 +02:00
2018-07-03 18:19:46 +02:00
2017-12-04 19:49:40 +08:00
2014-08-08 10:05:32 +02:00
2017-03-27 16:37:22 +02:00
2018-07-03 18:19:46 +02:00
2018-07-03 18:19:46 +02:00
2018-07-03 18:19:46 +02:00
2018-06-19 16:54:22 +03:00
2018-01-03 12:47:25 +08:00
2017-07-14 22:53:14 +01:00
2018-07-12 21:21:37 +08:00
2018-07-13 10:51:58 +02:00
2018-07-13 10:51:58 +02:00
2018-07-03 18:19:46 +02:00
2018-04-13 13:48:11 +02:00
2014-06-26 18:48:40 +02:00
2018-07-17 12:51:49 +03:00
2018-03-16 00:44:50 +08:00
2017-12-29 12:24:19 +02:00
2018-07-31 13:16:43 +02:00
2018-07-15 18:24:18 +03:00
2018-02-27 04:04:32 -08:00
2015-07-25 17:25:44 +02:00
2018-07-03 18:19:46 +02:00
2018-08-29 18:23:05 +08:00
2018-08-27 12:20:27 +02:00
2017-11-19 16:23:42 +00:00
2015-04-27 12:07:49 +02:00
2015-04-27 12:07:49 +02:00
2018-06-03 15:54:30 +03:00
2018-07-02 18:49:34 +02:00
2017-06-20 16:55:29 +02:00
2015-01-09 11:23:22 +01:00
2018-07-03 18:19:46 +02:00
2015-07-26 15:17:18 +02:00
2014-07-02 16:31:22 +02:00
2018-07-14 15:02:24 +08:00
2015-08-06 18:12:20 +02:00
2018-02-13 15:50:21 +01:00
2018-08-14 20:58:58 +08:00
2018-07-31 16:41:33 +02:00
2018-08-03 13:45:27 +02:00
2018-06-18 16:56:31 +02:00
2018-08-01 19:04:53 +02:00
2018-07-24 10:27:20 +02:00
2017-01-11 19:24:19 +02:00
2015-09-29 17:30:24 +02:00
2018-07-03 18:19:46 +02:00
2016-12-16 09:02:50 +01:00
2014-12-23 09:31:03 -05:00
2014-12-23 09:31:03 -05:00
2018-07-22 10:17:35 +03:00
2018-07-16 16:43:42 +03:00