diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-12-08 11:37:33 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-12-08 11:37:33 +0000 |
commit | b81a068aea8dca451b1f106ef191c0820db52c52 (patch) | |
tree | 4d1e9ee3ab573358d554925715e4d1f657258893 | |
parent | 315b61b3190f4b10f0710638bfaad27373fb3671 (diff) | |
download | rspamd-b81a068aea8dca451b1f106ef191c0820db52c52.tar.gz rspamd-b81a068aea8dca451b1f106ef191c0820db52c52.zip |
[Rework] Allow to restore SSL handlers after keepalive pooling
-rw-r--r-- | src/libserver/http/http_connection.c | 11 | ||||
-rw-r--r-- | src/libserver/ssl_util.c | 15 | ||||
-rw-r--r-- | src/libserver/ssl_util.h | 12 |
3 files changed, 38 insertions, 0 deletions
diff --git a/src/libserver/http/http_connection.c b/src/libserver/http/http_connection.c index 3dfe8e86c..e82c543c2 100644 --- a/src/libserver/http/http_connection.c +++ b/src/libserver/http/http_connection.c @@ -1260,6 +1260,17 @@ rspamd_http_connection_new_client_keepalive (struct rspamd_http_context *ctx, opts & RSPAMD_HTTP_CLIENT_SSL); if (conn) { + struct rspamd_http_connection_private *priv; + + priv = conn->priv; + + if (priv->ssl) { + rspamd_ssl_connection_restore_handlers (priv->ssl, + rspamd_http_event_handler, + rspamd_http_ssl_err_handler, + conn); + } + return conn; } diff --git a/src/libserver/ssl_util.c b/src/libserver/ssl_util.c index b4e905619..c229b6794 100644 --- a/src/libserver/ssl_util.c +++ b/src/libserver/ssl_util.c @@ -754,6 +754,21 @@ rspamd_ssl_connect_fd (struct rspamd_ssl_connection *conn, gint fd, return TRUE; } +void +rspamd_ssl_connection_restore_handlers (struct rspamd_ssl_connection *conn, + rspamd_ssl_handler_t handler, + rspamd_ssl_error_handler_t err_handler, + gpointer handler_data) +{ + conn->handler = handler; + conn->err_handler = err_handler; + conn->handler_data = handler_data; + + rspamd_ev_watcher_stop (conn->event_loop, conn->ev); + rspamd_ev_watcher_init (conn->ev, conn->fd, EV_WRITE, rspamd_ssl_event_handler, conn); + rspamd_ev_watcher_start (conn->event_loop, conn->ev, conn->ev->timeout); +} + gssize rspamd_ssl_read (struct rspamd_ssl_connection *conn, gpointer buf, gsize buflen) diff --git a/src/libserver/ssl_util.h b/src/libserver/ssl_util.h index f3593387f..f2d591b56 100644 --- a/src/libserver/ssl_util.h +++ b/src/libserver/ssl_util.h @@ -57,6 +57,18 @@ gboolean rspamd_ssl_connect_fd (struct rspamd_ssl_connection *conn, gint fd, gpointer handler_data); /** + * Restores SSL handlers for the existing ssl connection (e.g. after keepalive) + * @param conn + * @param handler + * @param err_handler + * @param handler_data + */ +void rspamd_ssl_connection_restore_handlers (struct rspamd_ssl_connection *conn, + rspamd_ssl_handler_t handler, + rspamd_ssl_error_handler_t err_handler, + gpointer handler_data); + +/** * Perform async read from SSL socket * @param conn * @param buf |