]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
server/afs: Close an unused file descriptor.
authorAndre Noll <maan@systemlinux.org>
Sat, 15 Sep 2007 22:36:13 +0000 (00:36 +0200)
committerAndre Noll <maan@systemlinux.org>
Sat, 15 Sep 2007 22:36:13 +0000 (00:36 +0200)
And mark file descriptors used for select() as non-blocking.

afs.c
server.c

diff --git a/afs.c b/afs.c
index 0efb6991fe20b4d7e5aadd5585841cc39f739a5f..a40948f27014813cc1fbbf26867da28e124ad07a 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -795,6 +795,9 @@ __noreturn int afs_init(uint32_t cookie, int socket_fd)
                exit(EXIT_FAILURE);
        }
        server_socket = socket_fd;
                exit(EXIT_FAILURE);
        }
        server_socket = socket_fd;
+       ret = mark_fd_nonblock(server_socket);
+       if (ret < 0)
+               exit(EXIT_FAILURE);
        PARA_INFO_LOG("server_socket: %d, afs_socket_cookie: %u\n",
                server_socket, (unsigned) cookie);
        current_play_mode = init_admissible_files();
        PARA_INFO_LOG("server_socket: %d, afs_socket_cookie: %u\n",
                server_socket, (unsigned) cookie);
        current_play_mode = init_admissible_files();
index 90f8cd535d67ac022284118e622e8f3528cf6099..e94de736f81b9508739dbf0f4c38c180ede29fdb 100644 (file)
--- a/server.c
+++ b/server.c
@@ -363,10 +363,16 @@ static void init_afs(void)
        afs_pid = fork();
        if (afs_pid < 0)
                exit(EXIT_FAILURE);
        afs_pid = fork();
        if (afs_pid < 0)
                exit(EXIT_FAILURE);
-       if (!afs_pid) /* child (afs) */
+       if (!afs_pid) { /* child (afs) */
+               close(afs_server_socket[0]);
                afs_init(afs_socket_cookie, afs_server_socket[1]);
                afs_init(afs_socket_cookie, afs_server_socket[1]);
+       }
        close(afs_server_socket[1]);
        afs_socket = afs_server_socket[0];
        close(afs_server_socket[1]);
        afs_socket = afs_server_socket[0];
+       ret = mark_fd_nonblock(afs_socket);
+       if (ret < 0)
+               exit(EXIT_FAILURE);
+       add_close_on_fork_list(afs_socket);
        PARA_INFO_LOG("afs_socket: %d, afs_socket_cookie: %u\n", afs_socket,
                (unsigned) afs_socket_cookie);
 }
        PARA_INFO_LOG("afs_socket: %d, afs_socket_cookie: %u\n", afs_socket,
                (unsigned) afs_socket_cookie);
 }