X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=server.c;h=e03d207adf8a639414b21c098885ad1f3f7263db;hp=1b3d724941802e0c1e5494e36c7cf01598a56e5a;hb=62414974b55d78a67d4170da85091a915087219f;hpb=b88a9a0cbbb39e999ae4942ed596b17ce2ae7f23 diff --git a/server.c b/server.c index 1b3d7249..e03d207a 100644 --- a/server.c +++ b/server.c @@ -77,12 +77,12 @@ #include "vss.h" #include "config.h" #include "close_on_fork.h" +#include "list.h" #include "send.h" #include "net.h" #include "daemon.h" #include "ipc.h" #include "fd.h" -#include "list.h" #include "sched.h" #include "signal.h" #include "user_list.h" @@ -325,25 +325,30 @@ err: static void init_random_seed(void) { - int fd, ret = -1; unsigned int seed; - size_t len = sizeof(unsigned int); + int fd, ret = para_open("/dev/urandom", O_RDONLY, 0); - fd = open("/dev/urandom", O_RDONLY); - if (fd < 0) + if (ret < 0) + goto err; + fd = ret; + ret = read(fd, &seed, sizeof(seed)); + if (ret < 0) { + ret = -ERRNO_TO_PARA_ERROR(errno); goto out; - ret = -2; - if (read(fd, &seed, len) != len) + } + if (ret != sizeof(seed)) { + ret = -ERRNO_TO_PARA_ERROR(EIO); goto out; + } srandom(seed); ret = 1; out: - if (fd >= 0) - close(fd); - if (ret > 0) + close(fd); + if (ret >= 0) return; - PARA_EMERG_LOG("can not seed pseudo random generator (ret = %d)\n", - ret); +err: + PARA_EMERG_LOG("can not seed pseudo random number generator: %s\n", + para_strerror(-ret)); exit(EXIT_FAILURE); } @@ -376,7 +381,6 @@ static void init_afs(void) (unsigned) afs_socket_cookie); } - static unsigned server_init(int argc, char **argv) { /* connector's address information */ @@ -399,11 +403,11 @@ static unsigned server_init(int argc, char **argv) PARA_NOTICE_LOG("initializing audio format handlers\n"); afh_init(); PARA_NOTICE_LOG("initializing virtual streaming system\n"); - vss_init(); mmd->server_pid = getpid(); setup_signal_handling(); PARA_NOTICE_LOG("initializing the audio file selector\n"); init_afs(); + vss_init(); mmd_lock(); /* init network socket */ PARA_NOTICE_LOG("initializing tcp command socket\n"); @@ -480,8 +484,6 @@ repeat: 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); @@ -493,8 +495,6 @@ repeat: if (ret < 0) goto repeat; for (i = 0; senders[i].name; i++) { - if (senders[i].status != SENDER_ON) - continue; if (!senders[i].post_select) continue; senders[i].post_select(&rfds, &wfds);