X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=server.c;h=bc143039563b830b07164efd96ac76a4f6d3e267;hp=edd382711d0c058e41f7a731a38e8c47cab0883a;hb=60ef885705932a682097ad2b9f2379282d814e79;hpb=b55f996a9d756a84b7fb880df6a9b917215ea058 diff --git a/server.c b/server.c index edd38271..bc143039 100644 --- a/server.c +++ b/server.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1997-2009 Andre Noll + * Copyright (C) 1997-2010 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -16,7 +16,7 @@ * - The main programs: \ref server.c, \ref audiod.c, \ref client.c, * \ref audioc.c, \ref afh.c * - Server: \ref server_command, \ref sender, - * - Audio file selector: \ref audio_format_handler, \ref mood, \ref afs_table, + * - Audio file selector: \ref audio_format_handler, \ref afs_table, * - Client: \ref receiver, \ref receiver_node, \ref filter, \ref filter_node. * * @@ -276,15 +276,13 @@ static void handle_sighup(void) kill(mmd->afs_pid, SIGHUP); } -static void signal_post_select(struct sched *s, struct task *t) +static void signal_post_select(struct sched *s, __a_unused struct task *t) { - struct signal_task *st = container_of(t, struct signal_task, task); + int signum = para_next_signal(&s->rfds); - if (!FD_ISSET(st->fd, &s->rfds)) + switch (signum) { + case 0: return; - - st->signum = para_next_signal(); - switch (st->signum) { case SIGHUP: handle_sighup(); break; @@ -304,7 +302,7 @@ static void signal_post_select(struct sched *s, struct task *t) /* die on sigint/sigterm. Kill all children too. */ case SIGINT: case SIGTERM: - PARA_EMERG_LOG("terminating on signal %d\n", st->signum); + PARA_EMERG_LOG("terminating on signal %d\n", signum); kill(0, SIGTERM); /* * We must wait for afs because afs catches SIGINT/SIGTERM. @@ -366,12 +364,9 @@ static void command_post_select(struct sched *s, struct task *t) pid_t child_pid; uint32_t *chunk_table; - if (!FD_ISSET(sct->listen_fd, &s->rfds)) - return; - ret = para_accept(sct->listen_fd, NULL, 0); - if (ret < 0) + ret = para_accept(sct->listen_fd, &s->rfds, NULL, 0, &new_fd); + if (ret <= 0) goto out; - new_fd = ret; peer_name = remote_name(new_fd); PARA_INFO_LOG("got connection from %s, forking\n", peer_name); mmd->num_connects++; @@ -425,7 +420,7 @@ static void init_server_command_task(int argc, char **argv) sct->task.post_select = command_post_select; sct->argc = argc; sct->argv = argv; - ret = para_listen(AF_UNSPEC, IPPROTO_TCP, conf.port_arg); + ret = para_listen_simple(IPPROTO_TCP, conf.port_arg); if (ret < 0) goto err; sct->listen_fd = ret;