]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - server.c
kill unused E_LIST_WRITERS_GIVEN
[paraslash.git] / server.c
index 8f20763fb44ed01327514b92837dceb8b0f66021..e10c1e0343c77f1462bb7117b38486f39161411f 100644 (file)
--- a/server.c
+++ b/server.c
@@ -41,6 +41,7 @@
 #include "daemon.h"
 #include "string.h"
 #include "ipc.h"
+#include "fd.h"
 
 /** define the array of error lists needed by para_server */
 INIT_SERVER_ERRLISTS;
@@ -134,15 +135,7 @@ void para_log(int ll, const char* fmt,...)
 
        if (ll < conf.loglevel_arg)
                return;
-       if (!logfile) {
-               if (ll < WARNING)
-                       outfd = stdout;
-               else
-                       outfd = stderr;
-       } else
-               outfd = logfile;
-       if (conf.daemon_given && !logfile)
-               return;
+       outfd = logfile? logfile : stderr;
        time(&t1);
        tm = localtime(&t1);
        strftime(str, MAXLINE, "%b %d %H:%M:%S", tm);
@@ -268,7 +261,6 @@ static void setup_signal_handling(void)
        int ret = 0;
 
        signal_pipe = para_signal_init();
-//     fcntl(signal_pipe, F_SETFL, O_NONBLOCK);
        PARA_NOTICE_LOG("%s", "setting up signal handlers\n");
        ret += para_install_sighandler(SIGINT);
        ret += para_install_sighandler(SIGTERM);
@@ -348,7 +340,7 @@ static unsigned do_inits(int argc, char **argv)
        init_random_seed();
        /* parse command line options */
        cmdline_parser(argc, argv, &conf);
-       para_drop_privileges(conf.user_arg);
+       para_drop_privileges(conf.user_arg, conf.group_arg);
        /* parse config file, open log and set defaults */
        parse_config(0);
        log_welcome("para_server", conf.loglevel_arg);
@@ -436,7 +428,7 @@ int main(int argc, char *argv[])
        /* listen on sock_fd, new connection on new_fd */
        int sockfd, new_fd;
        struct sockaddr_in their_addr;
-       int err, i, max_fileno, ret;
+       int i, max_fileno, ret;
        pid_t chld_pid;
        fd_set rfds, wfds;
        struct timeval *timeout;
@@ -450,7 +442,7 @@ repeat:
        FD_SET(sockfd, &rfds);
        max_fileno = sockfd;
        FD_SET(signal_pipe, &rfds);
-       max_fileno = MAX(max_fileno, signal_pipe);
+       max_fileno = PARA_MAX(max_fileno, signal_pipe);
 
        timeout = afs_preselect();
        status_refresh();
@@ -466,24 +458,17 @@ repeat:
        }
        if (selectors[mmd->selector_num].pre_select) {
                ret = selectors[mmd->selector_num].pre_select(&rfds, &wfds);
-               max_fileno = MAX(max_fileno, ret);
+               max_fileno = PARA_MAX(max_fileno, ret);
        }
        mmd_unlock();
-//     PARA_DEBUG_LOG("%s: select (max = %i)\n", __func__, max_fileno);
-       ret = select(max_fileno + 1, &rfds, &wfds, NULL, timeout);
-       err = errno;
-       //PARA_DEBUG_LOG("%s: select returned  %i\n", __func__, ret);
+       ret = para_select(max_fileno + 1, &rfds, &wfds, timeout);
        mmd_lock();
        if (mmd->selector_change >= 0)
                change_selector();
        if (selectors[mmd->selector_num].post_select)
                selectors[mmd->selector_num].post_select(&rfds, &wfds);
-       if (ret < 0 && err == EINTR)
-               goto repeat;
-       if (ret < 0) {
-               PARA_CRIT_LOG("select error (%s)\n", strerror(err));
+       if (ret < 0)
                goto repeat;
-       }
        for (i = 0; senders[i].name; i++) {
                if (senders[i].status != SENDER_ON)
                        continue;