]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
fix two bugs concerning blocking fds
authorAndre Noll <maan@congo.fml.local>
Sun, 8 Oct 2006 21:31:05 +0000 (23:31 +0200)
committerAndre Noll <maan@congo.fml.local>
Sun, 8 Oct 2006 21:31:05 +0000 (23:31 +0200)
para_server's command socked and the socket of the http_sender
were blocking file descriptors. So make them non-blocking.

http_send.c
server.c

index 111c49baf82aa58e9bb9172ad0a8deb86b9ee571..1d970a5df561a3395effa19abf0960a70af9c3ef 100644 (file)
@@ -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)
 {
 
 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;
        }
        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;
        self->status = SENDER_ON;
        add_close_on_fork_list(server_fd);
        return 1;
index c7e681264cddcd3fe7223b2492485be97869f4cc..9688c6ccf2cb4ac29723b0a8dd6f40627c16d934 100644 (file)
--- a/server.c
+++ b/server.c
@@ -302,11 +302,18 @@ random:
 
 static unsigned init_network(void)
 {
 
 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)
 }
 
 static void init_random_seed(void)