From 546dab32052ac277ad2d4d1903d357b340e0877f Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Thu, 19 Jan 2017 06:11:17 -0500 Subject: [PATCH] [core] permit connection-level state in modules (take 2: relocate module cleanup check to after handle_connection_close hook) modules may now keep state for the lifetime of a connection, rather than being required to be reset after every request (when there can be multiple keep-alive requests on the same connection) --- src/connections.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/connections.c b/src/connections.c index e56bd8b0..85c59024 100644 --- a/src/connections.c +++ b/src/connections.c @@ -138,6 +138,17 @@ static int connection_close(server *srv, connection *con) { "connection closed for fd", con->fd); } con->fd = -1; + + /* plugins should have cleaned themselves up */ + for (size_t i = 0; i < srv->plugins.used; ++i) { + plugin *p = ((plugin **)(srv->plugins.ptr))[i]; + plugin_data *pd = p->data; + if (!pd || NULL == con->plugin_ctx[pd->id]) continue; + log_error_write(srv, __FILE__, __LINE__, "sb", + "missing cleanup in", p->name); + con->plugin_ctx[pd->id] = NULL; + } + connection_del(srv, con); connection_set_state(srv, con, CON_STATE_CONNECT); @@ -180,16 +191,6 @@ static void connection_handle_shutdown(server *srv, connection *con) { srv->con_closed++; connection_reset(srv, con); - /* plugins should have cleaned themselves up */ - for (size_t i = 0; i < srv->plugins.used; ++i) { - plugin *p = ((plugin **)(srv->plugins.ptr))[i]; - plugin_data *pd = p->data; - if (!pd || NULL == con->plugin_ctx[pd->id]) continue; - log_error_write(srv, __FILE__, __LINE__, "sb", - "missing cleanup in", p->name); - con->plugin_ctx[pd->id] = NULL; - } - /* close the connection */ if ((0 == shutdown(con->fd, SHUT_WR))) { con->close_timeout_ts = srv->cur_ts;