提交 b9aa3328 编写于 作者: A antirez

Check write(2) return value to avoid warnings, because in this context failing...

Check write(2) return value to avoid warnings, because in this context failing write is not critical.
上级 3f64694e
......@@ -316,14 +316,15 @@ void redisLogFromHandler(int level, const char *msg) {
STDOUT_FILENO;
if (fd == -1) return;
ll2string(buf,sizeof(buf),getpid());
write(fd,"[",1);
write(fd,buf,strlen(buf));
write(fd," | signal handler] (",20);
if (write(fd,"[",1) == -1) goto err;
if (write(fd,buf,strlen(buf)) == -1) goto err;
if (write(fd," | signal handler] (",20) == -1) goto err;
ll2string(buf,sizeof(buf),time(NULL));
write(fd,buf,strlen(buf));
write(fd,") ",2);
write(fd,msg,strlen(msg));
write(fd,"\n",1);
if (write(fd,buf,strlen(buf)) == -1) goto err;
if (write(fd,") ",2) == -1) goto err;
if (write(fd,msg,strlen(msg)) == -1) goto err;
if (write(fd,"\n",1) == -1) goto err;
err:
if (server.logfile) close(fd);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册