From: Vsevolod Stakhov Date: Sun, 3 Nov 2019 14:33:42 +0000 (+0000) Subject: [Minor] One more thing about ssl_shutdown X-Git-Tag: 2.2~91 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c6db379233b0f15ba68f93286aea194b7ca5d4b6;p=rspamd.git [Minor] One more thing about ssl_shutdown --- diff --git a/src/libutil/ssl_util.c b/src/libutil/ssl_util.c index b65243989..d145e4f5b 100644 --- a/src/libutil/ssl_util.c +++ b/src/libutil/ssl_util.c @@ -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); }