提交 b91f03a4 编写于 作者: L Luc Heinrich

Fixed redis-cli readLine loop to correctly handle EOF.

When using the shutdown command with redis-cli the server saves the database and, if successful, silently closes the connection. The redis-cli tool did not correcty handle this EOF case in its readLine loop and was therefore infinitely looping - and eating 100% of the CPU - while waiting for some data which would never come.
上级 46713f83
......@@ -135,11 +135,13 @@ static sds cliReadLine(int fd) {
while(1) {
char c;
ssize_t ret;
if (read(fd,&c,1) == -1) {
ret = read(fd,&c,1);
if (ret == -1) {
sdsfree(line);
return NULL;
} else if (c == '\n') {
} else if ((ret == 0) || (c == '\n')) {
break;
} else {
line = sdscatlen(line,&c,1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册