[server] setsockopt() nad fcntl() return value checking (found by Coverity)

This commit is contained in:
Michael Rash
2013-05-09 22:35:08 -04:00
parent 72e4edbf6a
commit aafc3ac264
2 changed files with 12 additions and 2 deletions
+6 -1
View File
@@ -621,7 +621,12 @@ write_pid_file(fko_srv_options_t *opts)
return -1;
}
fcntl(op_fd, F_SETFD, FD_CLOEXEC);
if(fcntl(op_fd, F_SETFD, FD_CLOEXEC) == -1)
{
close(op_fd);
perror("Unexpected error from fcntl: ");
return -1;
}
/* Attempt to lock the PID file. If we get an EWOULDBLOCK
* error, another instance already has the lock. So we grab
+6 -1
View File
@@ -108,7 +108,12 @@ run_tcp_server(fko_srv_options_t *opts)
/* So that we can re-bind to it without TIME_WAIT problems
*/
setsockopt(s_sock, SOL_SOCKET, SO_REUSEADDR, &reuse_addr, sizeof(reuse_addr));
if(setsockopt(s_sock, SOL_SOCKET, SO_REUSEADDR, &reuse_addr, sizeof(reuse_addr)) == -1)
{
log_msg(LOG_ERR, "run_tcp_server: setsockopt error: %s",
strerror(errno));
exit(EXIT_FAILURE);
}
/* Make our main socket non-blocking so we don't have to be stuck on
* listening for incoming connections.