diff options
author | antirez <antirez@gmail.com> | 2015-08-05 16:51:50 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2015-08-05 17:00:04 +0200 |
commit | be56e4cf3311017c36d1be6b249cd7c642278b17 (patch) | |
tree | 9d290ec597c7b4e8ed9fb4ab41c9d52d809b25e0 | |
parent | a67d67b561b6416cee3fb6c0f7c575f8fa93fc18 (diff) | |
download | redis-be56e4cf3311017c36d1be6b249cd7c642278b17.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; |