From c4012aab461993e6c8a9930d27d924a8462a9775 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 8 Oct 2006 23:31:05 +0200 Subject: [PATCH] fix two bugs concerning blocking fds para_server's command socked and the socket of the http_sender were blocking file descriptors. So make them non-blocking. --- http_send.c | 7 +++++++ server.c | 15 +++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/http_send.c b/http_send.c index 111c49ba..1d970a5d 100644 --- a/http_send.c +++ b/http_send.c @@ -371,12 +371,19 @@ static void http_pre_select(int *max_fileno, fd_set *rfds, fd_set *wfds) 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; diff --git a/server.c b/server.c index c7e68126..9688c6cc 100644 --- a/server.c +++ b/server.c @@ -302,11 +302,18 @@ random: 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) -- 2.39.5