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
2016-04-25 16:49:57 +03:00
2016-06-07 16:46:00 -04:00
2018-07-04 20:04:06 +08:00
2018-03-21 15:34:13 +08:00
2016-04-04 08:50:58 +02:00
2018-07-03 18:19:46 +02: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
2018-07-03 18:19:46 +02: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
2018-07-03 18:19:46 +02:00
2018-06-21 22:08:09 +08:00
2018-07-03 18:19:46 +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
2018-07-03 18:19:46 +02:00
2018-07-13 09:46:30 -06:00
2018-07-30 16:18:56 +03:00
2018-07-03 18:19:46 +02:00
2014-08-08 10:05:32 +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-07-12 21:21:37 +08:00
2018-07-03 18:19:46 +02:00
2018-07-03 18:19:46 +02:00
2015-04-27 12:07:49 +02:00
2015-04-27 12:07:49 +02:00
2018-07-03 18:19:46 +02:00
2014-07-02 16:31:22 +02:00
2018-07-31 16:41:33 +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
2018-07-03 18:19:46 +02:00
2018-07-22 10:17:35 +03:00