Handle sender commands in vss_post_select().
[paraslash.git] / server.c
index 98e208ac39d9212d67491faf0ad69e21af785128..a287890c4ca20c248c681d79038ad5f378b9d858 100644 (file)
--- a/server.c
+++ b/server.c
@@ -205,7 +205,7 @@ static void shm_init(void)
        mmd->sender_cmd_data.cmd_num = -1;
        return;
 err_out:
        mmd->sender_cmd_data.cmd_num = -1;
        return;
 err_out:
-       PARA_EMERG_LOG("%s", para_strerror(-ret));
+       PARA_EMERG_LOG("%s\n", para_strerror(-ret));
        exit(EXIT_FAILURE);
 }
 
        exit(EXIT_FAILURE);
 }
 
@@ -257,18 +257,13 @@ static void parse_config(int override)
                struct server_cmdline_parser_params params = {
                        .override = override,
                        .initialize = 0,
                struct server_cmdline_parser_params params = {
                        .override = override,
                        .initialize = 0,
-                       .check_required = 0,
-                       .check_ambiguity = 0
+                       .check_required = 1,
+                       .check_ambiguity = 0,
+                       .print_errors = 1
                };
                server_cmdline_parser_config_file(cf, &conf, &params);
                conf.daemon_given = tmp;
        }
                };
                server_cmdline_parser_config_file(cf, &conf, &params);
                conf.daemon_given = tmp;
        }
-       /* logfile */
-       if (!conf.logfile_given && conf.daemon_given) {
-               ret = -1;
-               PARA_EMERG_LOG("fatal: daemon option, but no log file given\n");
-               goto out;
-       }
        if (conf.logfile_given)
                logfile = open_log(conf.logfile_arg);
        ret = 1;
        if (conf.logfile_given)
                logfile = open_log(conf.logfile_arg);
        ret = 1;
@@ -385,10 +380,16 @@ static unsigned server_init(int argc, char **argv)
 {
        /* connector's address information */
        int sockfd;
 {
        /* connector's address information */
        int sockfd;
-
+       struct server_cmdline_parser_params params = {
+               .override = 0,
+               .initialize = 1,
+               .check_required = 0,
+               .check_ambiguity = 0,
+               .print_errors = 1
+       };
        init_random_seed();
        /* parse command line options */
        init_random_seed();
        /* parse command line options */
-       server_cmdline_parser(argc, argv, &conf);
+       server_cmdline_parser_ext(argc, argv, &conf, &params);
        HANDLE_VERSION_FLAG("server", conf);
        para_drop_privileges(conf.user_arg, conf.group_arg);
        /* parse config file, open log and set defaults */
        HANDLE_VERSION_FLAG("server", conf);
        para_drop_privileges(conf.user_arg, conf.group_arg);
        /* parse config file, open log and set defaults */
@@ -421,7 +422,7 @@ static unsigned server_init(int argc, char **argv)
  */
 static void handle_sighup(void)
 {
  */
 static void handle_sighup(void)
 {
-       PARA_NOTICE_LOG("%s", "SIGHUP\n");
+       PARA_NOTICE_LOG("SIGHUP\n");
        close_log(logfile); /* gets reopened if necessary by parse_config */
        logfile = NULL;
        parse_config(1); /* reopens log */
        close_log(logfile); /* gets reopened if necessary by parse_config */
        logfile = NULL;
        parse_config(1); /* reopens log */
@@ -483,23 +484,12 @@ repeat:
        para_fd_set(signal_pipe, &rfds, &max_fileno);
        timeout = vss_preselect(&rfds, &wfds, &max_fileno);
        status_refresh();
        para_fd_set(signal_pipe, &rfds, &max_fileno);
        timeout = vss_preselect(&rfds, &wfds, &max_fileno);
        status_refresh();
-       for (i = 0; senders[i].name; i++) {
-               if (!senders[i].pre_select)
-                       continue;
-               senders[i].pre_select(&max_fileno, &rfds, &wfds);
-       }
        mmd_unlock();
        ret = para_select(max_fileno + 1, &rfds, &wfds, timeout);
        mmd_lock();
        mmd_unlock();
        ret = para_select(max_fileno + 1, &rfds, &wfds, timeout);
        mmd_lock();
-       vss_post_select(&rfds, &wfds);
        if (ret < 0)
                goto repeat;
        if (ret < 0)
                goto repeat;
-       for (i = 0; senders[i].name; i++) {
-               if (!senders[i].post_select)
-                       continue;
-               senders[i].post_select(&rfds, &wfds);
-       }
-       vss_send_chunk();
+       vss_post_select(&rfds, &wfds);
        status_refresh();
        if (FD_ISSET(signal_pipe, &rfds)) {
                int sig;
        status_refresh();
        if (FD_ISSET(signal_pipe, &rfds)) {
                int sig;
@@ -533,14 +523,6 @@ genocide:
                        exit(EXIT_FAILURE);
                }
        }
                        exit(EXIT_FAILURE);
                }
        }
-       if (mmd->sender_cmd_data.cmd_num >= 0) {
-               int num = mmd->sender_cmd_data.cmd_num,
-                       s = mmd->sender_cmd_data.sender_num;
-
-               if (senders[s].client_cmds[num])
-                       senders[s].client_cmds[num](&mmd->sender_cmd_data);
-               mmd->sender_cmd_data.cmd_num = -1;
-       }
        if (!FD_ISSET(sockfd, &rfds))
                goto repeat;
 
        if (!FD_ISSET(sockfd, &rfds))
                goto repeat;
 
@@ -554,7 +536,7 @@ genocide:
        random();
        chld_pid = fork();
        if (chld_pid < 0) {
        random();
        chld_pid = fork();
        if (chld_pid < 0) {
-               PARA_CRIT_LOG("%s", "fork failed\n");
+               PARA_CRIT_LOG("fork failed\n");
                goto repeat;
        }
        if (chld_pid) {
                goto repeat;
        }
        if (chld_pid) {