From 8b6b83a6f6ee18ecd580fa7c6d60eba51b3866ce Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Wed, 13 May 2015 14:27:27 +0200 Subject: [PATCH] when the server exits don't wait for stats from sec-mod --- src/main-ctl.h | 2 +- src/main-misc.c | 4 ++-- src/main.c | 6 +++--- src/main.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main-ctl.h b/src/main-ctl.h index ac3881dd..f9580b2f 100644 --- a/src/main-ctl.h +++ b/src/main-ctl.h @@ -16,7 +16,7 @@ inline static void terminate_proc(main_server_st *s, proc_st *proc) if (proc->pid != -1 && proc->pid != 0) kill(proc->pid, SIGTERM); else - remove_proc(s, proc, 1); + remove_proc(s, proc, 1, 0); } #endif diff --git a/src/main-misc.c b/src/main-misc.c index ae94d025..3b371200 100644 --- a/src/main-misc.c +++ b/src/main-misc.c @@ -167,7 +167,7 @@ struct proc_st *ctmp; /* k: whether to kill the process */ -void remove_proc(main_server_st * s, struct proc_st *proc, unsigned k) +void remove_proc(main_server_st * s, struct proc_st *proc, unsigned k, unsigned quit) { mslog(s, proc, LOG_INFO, "user disconnected"); @@ -178,7 +178,7 @@ void remove_proc(main_server_st * s, struct proc_st *proc, unsigned k) kill(proc->pid, SIGTERM); /* close any pending sessions */ - if (proc->active_sid) { + if (proc->active_sid && quit == 0) { session_close(s, proc); } diff --git a/src/main.c b/src/main.c index 10a29069..a3d4c627 100644 --- a/src/main.c +++ b/src/main.c @@ -500,7 +500,7 @@ struct script_wait_st *stmp = NULL, *spos; list_del(&stmp->list); ret = handle_script_exit(s, stmp->proc, estatus); if (ret < 0) { - remove_proc(s, stmp->proc, 1); + remove_proc(s, stmp->proc, 1, 0); } else { talloc_free(stmp); } @@ -660,7 +660,7 @@ static void kill_children(main_server_st* s) kill(s->sec_mod_pid, SIGTERM); list_for_each_safe(&s->proc_list.head, ctmp, cpos, list) { if (ctmp->pid != -1) { - remove_proc(s, ctmp, 1); + remove_proc(s, ctmp, 1, 1); } } } @@ -1267,7 +1267,7 @@ fork_failed: if (ctmp->fd >= 0 && FD_ISSET(ctmp->fd, &rd_set)) { ret = handle_commands(s, ctmp); if (ret < 0) { - remove_proc(s, ctmp, (ret!=ERR_WORKER_TERMINATED)?1:0); + remove_proc(s, ctmp, (ret!=ERR_WORKER_TERMINATED)?1:0, 0); } } } diff --git a/src/main.h b/src/main.h index dd3c191a..1e0b283e 100644 --- a/src/main.h +++ b/src/main.h @@ -269,7 +269,7 @@ int run_sec_mod(main_server_st * s, int *sync_fd); struct proc_st *new_proc(main_server_st * s, pid_t pid, int cmd_fd, struct sockaddr_storage *remote_addr, socklen_t remote_addr_len, uint8_t *sid, size_t sid_size); -void remove_proc(main_server_st* s, struct proc_st *proc, unsigned k); +void remove_proc(main_server_st* s, struct proc_st *proc, unsigned k, unsigned quit); void proc_to_zombie(main_server_st* s, struct proc_st *proc); void put_into_cgroup(main_server_st * s, const char* cgroup, pid_t pid);