]> jfr.im git - solanum.git/blobdiff - ircd/sslproc.c
client: always purge a client from the connid table, as connid is not related to FD
[solanum.git] / ircd / sslproc.c
index 3b4be1a8e0e1928413267d6f3b298c0adb840607..9b79a2461d3c48be709adc92623c894b05cb1bd4 100644 (file)
@@ -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)
 {