]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] One more thing about ssl_shutdown
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 3 Nov 2019 14:33:42 +0000 (14:33 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 3 Nov 2019 14:33:42 +0000 (14:33 +0000)
src/libutil/ssl_util.c

index b65243989a877febea21148af0cf8c8f9b8e6138..d145e4f5ba7862e4e27e6847e7fc5fdf0ca0830c 100644 (file)
@@ -492,13 +492,18 @@ rspamd_ssl_shutdown (struct rspamd_ssl_connection *conn)
                /* BUGON: but we DO NOT own conn->ev, and it's a big issue */
                static const ev_tstamp shutdown_time = 5.0;
 
-               rspamd_ev_watcher_stop (conn->event_loop, conn->ev);
-               conn->shut_ev = g_malloc0 (sizeof (*conn->shut_ev));
-               rspamd_ev_watcher_init (conn->shut_ev, conn->fd, what,
-                               rspamd_ssl_event_handler, conn);
-               rspamd_ev_watcher_start (conn->event_loop, conn->shut_ev, shutdown_time);
-               /* XXX: can it be done safely ? */
-               conn->ev = conn->shut_ev;
+               if (conn->shut_ev == NULL) {
+                       rspamd_ev_watcher_stop (conn->event_loop, conn->ev);
+                       conn->shut_ev = g_malloc0 (sizeof (*conn->shut_ev));
+                       rspamd_ev_watcher_init (conn->shut_ev, conn->fd, what,
+                                       rspamd_ssl_event_handler, conn);
+                       rspamd_ev_watcher_start (conn->event_loop, conn->shut_ev, shutdown_time);
+                       /* XXX: can it be done safely ? */
+                       conn->ev = conn->shut_ev;
+               }
+               else {
+                       rspamd_ev_watcher_reschedule (conn->event_loop, conn->shut_ev, what);
+               }
 
                conn->state = ssl_next_shutdown;
        }
@@ -900,6 +905,7 @@ rspamd_ssl_connection_free (struct rspamd_ssl_connection *conn)
                if (conn->shut == ssl_shut_unclean) {
                        /* Ignore return result and close socket */
                        msg_debug_ssl ("unclean shutdown");
+                       SSL_set_quiet_shutdown (conn->ssl, 1);
                        (void)SSL_shutdown (conn->ssl);
                        rspamd_ssl_connection_dtor (conn);
                }