Skip to content

Commit

Permalink
Check write(2) return value to avoid warnings, because in this contex…
Browse files Browse the repository at this point in the history
…t failing write is not critical.
  • Loading branch information
antirez committed Apr 10, 2012
1 parent a3fb7fd commit 0b913c6
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/redis.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,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);
}

Expand Down

0 comments on commit 0b913c6

Please sign in to comment.