X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=server.c;h=3cc7e7892ad3d8ceade6f08dcc8ea1417c44e308;hp=94e6564b783371fb8cd77e9f8c0a96eb55093f6f;hb=9be5a49b2b24d49de40f87f9aba3378dd04a7b0e;hpb=cb6d1dfb9e4067229a4bbde0abd05784d97ef14b diff --git a/server.c b/server.c index 94e6564b..3cc7e789 100644 --- a/server.c +++ b/server.c @@ -15,25 +15,30 @@ * */ +#include +#include +#include #include "para.h" +#include "error.h" #include "server.cmdline.h" #include "afs_common.h" #include "afh.h" +#include "string.h" +#include "afs.h" #include "server.h" #include "vss.h" #include "config.h" #include "close_on_fork.h" #include "send.h" -#include "error.h" #include "net.h" #include "daemon.h" -#include "string.h" #include "ipc.h" #include "fd.h" +#include "list.h" +#include "sched.h" #include "signal.h" #include "user_list.h" -#include "afs.h" /** define the array of error lists needed by para_server */ INIT_SERVER_ERRLISTS; @@ -346,9 +351,9 @@ out: exit(EXIT_FAILURE); } -static uint32_t afs_socket_cookie; -static int afs_socket; -pid_t afs_pid; +uint32_t afs_socket_cookie; +int afs_socket; +static pid_t afs_pid; static void init_afs(void) { @@ -361,10 +366,16 @@ static void init_afs(void) 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]); + } 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); } @@ -392,6 +403,7 @@ static unsigned do_inits(int argc, char **argv) init_selector(); // PARA_ERROR_LOG("num: %d\n", mmd->selector_num); PARA_NOTICE_LOG("%s", "initializing virtual streaming system\n"); + afh_init(); vss_init(); mmd->server_pid = getpid(); setup_signal_handling(); @@ -433,6 +445,8 @@ static void handle_sighup(void) mmd->selector_change = mmd->selector_num; /* do not change selector.. */ change_selector(); /* .. just reload */ init_user_list(user_list_file); /* reload user list */ + if (afs_pid) + kill(afs_pid, SIGHUP); } static void status_refresh(void) @@ -486,14 +500,14 @@ repeat: /* check socket and signal pipe in any case */ para_fd_set(sockfd, &rfds, &max_fileno); para_fd_set(signal_pipe, &rfds, &max_fileno); - timeout = vss_preselect(); + timeout = vss_preselect(&rfds, &wfds, &max_fileno); status_refresh(); for (i = 0; senders[i].name; i++) { if (senders[i].status != SENDER_ON) continue; if (!senders[i].pre_select) continue; - senders[i].pre_select( &max_fileno, &rfds, &wfds); + senders[i].pre_select(&max_fileno, &rfds, &wfds); } if (selectors[mmd->selector_num].pre_select) { ret = selectors[mmd->selector_num].pre_select(&rfds, &wfds); @@ -502,6 +516,7 @@ repeat: mmd_unlock(); ret = para_select(max_fileno + 1, &rfds, &wfds, timeout); mmd_lock(); + vss_post_select(&rfds, &wfds); if (mmd->selector_change >= 0) change_selector(); if (selectors[mmd->selector_num].post_select) @@ -527,8 +542,8 @@ repeat: break; case SIGCHLD: for (;;) { - pid = para_reap_child(); - if (pid <= 0) + ret = para_reap_child(&pid); + if (ret <= 0) break; if (pid != afs_pid) continue;