X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=server.c;h=e963da7760465af02bcceec58730be2be4be84fd;hp=ef79a2e88d7577dc882fba229d9141a0c55a1549;hb=74c88020bd325865fe26ed25ea8ad0ace0924136;hpb=8aa0f575bcca12ab63ab53141c2144448c457478 diff --git a/server.c b/server.c index ef79a2e8..e963da77 100644 --- a/server.c +++ b/server.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1997-2011 Andre Noll + * Copyright (C) 1997-2013 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -14,10 +14,11 @@ * * * - The main programs: \ref server.c, \ref audiod.c, \ref client.c, - * \ref audioc.c, \ref afh.c + * \ref audioc.c, \ref afh.c, \ref play.c, * - Server: \ref server_command, \ref sender, * - Audio file selector: \ref audio_format_handler, \ref afs_table, - * - Client: \ref receiver, \ref receiver_node, \ref filter, \ref filter_node. + * - Client: \ref receiver, \ref receiver_node, \ref filter, + * \ref filter_node, \ref writer_node. * * * The gory details, listed by topic: @@ -26,6 +27,7 @@ * \ref ogg_afh.c, \ref aac_afh.c, \ref wma_afh.c, \ref spx_afh.c * - Decoders: \ref mp3dec_filter.c, \ref oggdec_filter.c, * \ref aacdec_filter.c, \ref wmadec_filter.c, spxdec_filter.c, + * \ref flacdec_filter.c, * - Volume normalizer: \ref compress_filter.c, * - Output: \ref alsa_write.c, \ref osx_write.c, \ref oss_write.c, * - http: \ref http_recv.c, \ref http_send.c, @@ -50,9 +52,10 @@ * - Spawning processes: \ref exec.c, * - Inter process communication: \ref ipc.c, * - Blob tables: \ref blob.c, - * - The error subssystem: \ref error.h. + * - The error subsystem: \ref error.h. * - Access control for paraslash senders: \ref acl.c, \ref acl.h. * - Internal crypto API: \ref crypt.h. + * - interactive sessions (libreadline): \ref interactive.c. * * Low-level data structures: * @@ -64,10 +67,8 @@ */ #include -#include #include #include -#include #include "para.h" #include "error.h" @@ -277,13 +278,13 @@ static void handle_sighup(void) kill(mmd->afs_pid, SIGHUP); } -static void signal_post_select(struct sched *s, __a_unused struct task *t) +static int signal_post_select(struct sched *s, __a_unused struct task *t) { int signum = para_next_signal(&s->rfds); switch (signum) { case 0: - return; + return 0; case SIGHUP: handle_sighup(); break; @@ -328,6 +329,7 @@ cleanup: shm_detach(mmd); exit(EXIT_FAILURE); } + return 0; } static void init_signal_task(void) @@ -336,7 +338,7 @@ static void init_signal_task(void) *st = &signal_task_struct; st->task.pre_select = signal_pre_select; - st->task.post_select = signal_post_select; + st->task.new_post_select = signal_post_select; sprintf(st->task.status, "signal task"); PARA_NOTICE_LOG("setting up signal handling\n"); @@ -356,7 +358,7 @@ static void command_pre_select(struct sched *s, struct task *t) para_fd_set(sct->listen_fd, &s->rfds, &s->max_fileno); } -static void command_post_select(struct sched *s, struct task *t) +static int command_post_select(struct sched *s, struct task *t) { struct server_command_task *sct = container_of(t, struct server_command_task, task); @@ -390,7 +392,7 @@ static void command_post_select(struct sched *s, struct task *t) if (child_pid) { close(new_fd); /* parent keeps accepting connections */ - return; + return 0; } /* mmd might already have changed at this point */ free(chunk_table); @@ -404,10 +406,12 @@ static void command_post_select(struct sched *s, struct task *t) for (i = sct->argc - 1; i >= 0; i--) memset(sct->argv[i], 0, strlen(sct->argv[i])); sprintf(sct->argv[0], "para_server (serving %s)", peer_name); - return handle_connect(new_fd, peer_name); + handle_connect(new_fd, peer_name); + /* never reached*/ out: if (ret < 0) PARA_CRIT_LOG("%s\n", para_strerror(-ret)); + return 0; } static void init_server_command_task(int argc, char **argv) @@ -418,7 +422,7 @@ static void init_server_command_task(int argc, char **argv) PARA_NOTICE_LOG("initializing tcp command socket\n"); sct->task.pre_select = command_pre_select; - sct->task.post_select = command_post_select; + sct->task.new_post_select = command_post_select; sct->argc = argc; sct->argv = argv; ret = para_listen_simple(IPPROTO_TCP, conf.port_arg); @@ -491,7 +495,7 @@ static void server_init(int argc, char **argv) log_welcome("para_server"); init_ipc_or_die(); /* init mmd struct and mmd->lock */ /* make sure, the global now pointer is uptodate */ - gettimeofday(now, NULL); + clock_get_realtime(now); set_server_start_time(now); init_user_list(user_list_file); /* become daemon */