para_server's command socked and the socket of the http_sender
were blocking file descriptors. So make them non-blocking.
static int open_tcp_port(int port)
{
+ int ret;
+
server_fd = init_tcp_socket(port);
if (server_fd < 0) {
http_shutdown_clients();
self->status = SENDER_OFF;
return server_fd;
}
+ ret = mark_fd_nonblock(server_fd);
+ if (ret < 0) {
+ PARA_EMERG_LOG("%s\n", PARA_STRERROR(-ret));
+ exit(EXIT_FAILURE);
+ }
self->status = SENDER_ON;
add_close_on_fork_list(server_fd);
return 1;
static unsigned init_network(void)
{
- int sockfd = init_tcp_socket(conf.port_arg);
+ int fd, ret = init_tcp_socket(conf.port_arg);
- if (sockfd < 0)
- exit(EXIT_FAILURE);
- return sockfd;
+ if (ret < 0)
+ goto err;
+ fd = ret;
+ ret = mark_fd_nonblock(fd);
+ if (ret < 0)
+ goto err;
+ return fd;
+err:
+ PARA_EMERG_LOG("%s\n", PARA_STRERROR(-ret));
+ exit(EXIT_FAILURE);
}
static void init_random_seed(void)