X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=server.c;h=d51e4e0bfe5b33c341ff744eda4f9380bd666844;hb=refs%2Fheads%2Fmaint;hp=e0d50f4f8689e1de283ef80f8341504bcf386d33;hpb=b3c68fd8519a426d6b6285dcb5a865670285e99a;p=paraslash.git diff --git a/server.c b/server.c index e0d50f4f..d51e4e0b 100644 --- a/server.c +++ b/server.c @@ -110,7 +110,7 @@ static struct signal_task *signal_task; /** The process id of the audio file selector process. */ pid_t afs_pid = 0; -/* The the main server process (parent of afs and the command handlers). */ +/* The main server process (parent of afs and the command handlers). */ static pid_t server_pid; /** @@ -298,14 +298,14 @@ static int signal_post_select(struct sched *s, __a_unused void *context) if (pid != afs_pid) continue; PARA_EMERG_LOG("fatal: afs died\n"); - kill(0, SIGTERM); - goto cleanup; + goto genocide; } break; /* die on sigint/sigterm. Kill all children too. */ case SIGINT: case SIGTERM: PARA_EMERG_LOG("terminating on signal %d\n", signum); +genocide: kill(0, SIGTERM); /* * We must wait for all of our children to die. For the afs @@ -320,7 +320,6 @@ static int signal_post_select(struct sched *s, __a_unused void *context) while (wait(NULL) != -1 || errno != ECHILD) ; /* still at least one child alive */ mutex_lock(mmd_mutex); -cleanup: free(mmd->afd.afhi.chunk_table); task_notify_all(s, E_DEADLY_SIGNAL); return -E_DEADLY_SIGNAL; @@ -433,15 +432,16 @@ static int command_post_select(struct sched *s, void *context) ret = task_get_notification(sct->task); if (ret < 0) - return ret; + goto fail; for (n = 0; n < sct->num_listen_fds; n++) { ret = command_task_accept(n, s, sct); - if (ret < 0) { - free(sct->listen_fds); - return ret; - } + if (ret < 0) + goto fail; } return 0; +fail: + free(sct->listen_fds); + return ret; } static void init_server_command_task(struct server_command_task *sct,