[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)personal/stbuehler/mod-csrf
parent
b1405360fe
commit
546dab3205
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue