diff options
author | antirez <antirez@gmail.com> | 2015-08-05 16:51:50 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2015-08-05 16:51:50 +0200 |
commit | 7ab3af0edc238c869827c185f997c0a99f4506b5 (patch) | |
tree | 866fdc7e02a4c2ac1bdc5573478fea3df91fb103 | |
parent | 55ba77270363400625f4563788d8f842408389a2 (diff) | |
download | redis-7ab3af0edc238c869827c185f997c0a99f4506b5.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 48e0a0b79..1d0e663c7 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; |