diff options
author | antirez <antirez@gmail.com> | 2015-08-05 16:51:50 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2015-08-05 16:59:23 +0200 |
commit | ade9bf7cb30de2894d4413129e0efee49348882d (patch) | |
tree | 87e4f6f372afded57cd720f479fcee943a26623b | |
parent | 64b28d1097053da03d25afbe0ded80f24af7ca36 (diff) | |
download | redis-ade9bf7cb30de2894d4413129e0efee49348882d.tar.gz |
Fix synchronous readline "\n" handling.
Our function to read a line with a timeout handles newlines as requests
to refresh the timeout, however the code kept subtracting the buffer
size left every time a newline was received, for a bug in the loop
logic. Fixed by this commit.
-rw-r--r-- | src/syncio.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/syncio.c b/src/syncio.c index 22a345c6e..49be41c15 100644 --- a/src/syncio.c +++ b/src/syncio.c @@ -138,6 +138,9 @@ ssize_t syncReadLine(int fd, char *ptr, ssize_t size, long long timeout) { *ptr = '\0'; if (nread && *(ptr-1) == '\r') *(ptr-1) = '\0'; return nread; + } else { + /* Read again with a fresh timeout. */ + continue; } } else { *ptr++ = c; |