X-Git-Url: https://jfr.im/git/solanum.git/blobdiff_plain/dea27a087cd55265315c1bb5d30f8e72e9aea1e4..36f0ec74c10d3bf712f4041c5ed1ad83d405aaa3:/ircd/sslproc.c diff --git a/ircd/sslproc.c b/ircd/sslproc.c index 3b4be1a8..9b79a246 100644 --- a/ircd/sslproc.c +++ b/ircd/sslproc.c @@ -66,6 +66,7 @@ struct _ssl_ctl pid_t pid; rb_dlink_list readq; rb_dlink_list writeq; + uint8_t shutdown; uint8_t dead; }; @@ -150,6 +151,31 @@ static time_t last_spin; static int ssld_wait = 0; +void +restart_ssld(void) +{ + rb_dlink_node *ptr, *next; + ssl_ctl_t *ctl; + + RB_DLINK_FOREACH_SAFE(ptr, next, ssl_daemons.head) + { + ctl = ptr->data; + if(ctl->dead) + continue; + if(ctl->shutdown) + continue; + ctl->shutdown = 1; + ssld_count--; + if(!ctl->cli_count) + { + rb_kill(ctl->pid, SIGKILL); + free_ssl_daemon(ctl); + } + } + + start_ssldaemon(ServerInfo.ssld_count, ServerInfo.ssl_cert, ServerInfo.ssl_private_key, ServerInfo.ssl_dh_params, ServerInfo.ssl_cipher_list); +} + static void ssl_killall(void) { @@ -161,8 +187,11 @@ ssl_killall(void) if(ctl->dead) continue; ctl->dead = 1; - ssld_count--; + if(!ctl->shutdown) + ssld_count--; rb_kill(ctl->pid, SIGKILL); + if(!ctl->cli_count) + free_ssl_daemon(ctl); } } @@ -173,11 +202,15 @@ ssl_dead(ssl_ctl_t * ctl) return; ctl->dead = 1; - ssld_count--; rb_kill(ctl->pid, SIGKILL); /* make sure the process is really gone */ - ilog(L_MAIN, "ssld helper died - attempting to restart"); - sendto_realops_snomask(SNO_GENERAL, L_ALL, "ssld helper died - attempting to restart"); - start_ssldaemon(1, ServerInfo.ssl_cert, ServerInfo.ssl_private_key, ServerInfo.ssl_dh_params, ServerInfo.ssl_cipher_list); + + if(!ctl->shutdown) + { + ssld_count--; + ilog(L_MAIN, "ssld helper died - attempting to restart"); + sendto_realops_snomask(SNO_GENERAL, L_ALL, "ssld helper died - attempting to restart"); + start_ssldaemon(1, ServerInfo.ssl_cert, ServerInfo.ssl_private_key, ServerInfo.ssl_dh_params, ServerInfo.ssl_cipher_list); + } } static void @@ -541,6 +574,8 @@ which_ssld(void) ctl = ptr->data; if(ctl->dead) continue; + if(ctl->shutdown) + continue; if(lowest == NULL) { lowest = ctl; @@ -737,6 +772,11 @@ ssld_decrement_clicount(ssl_ctl_t * ctl) return; ctl->cli_count--; + if(ctl->shutdown && !ctl->cli_count) + { + ctl->dead = 1; + rb_kill(ctl->pid, SIGKILL); + } if(ctl->dead && !ctl->cli_count) { free_ssl_daemon(ctl); @@ -897,6 +937,20 @@ get_ssld_count(void) return ssld_count; } +void +ssld_foreach_info(void (*func)(void *data, pid_t pid, int cli_count, enum ssld_status status), void *data) +{ + rb_dlink_node *ptr, *next; + ssl_ctl_t *ctl; + RB_DLINK_FOREACH_SAFE(ptr, next, ssl_daemons.head) + { + ctl = ptr->data; + func(data, ctl->pid, ctl->cli_count, + ctl->dead ? SSLD_DEAD : + (ctl->shutdown ? SSLD_SHUTDOWN : SSLD_ACTIVE)); + } +} + void init_ssld(void) {