Standalone: independently destroy the connection and request pools

Add independent modsecFinishConnection API that allows you to independently
destroy the connection and request pools. This is to facilitate reuse of a
connection for multiple requests.
This commit is contained in:
David Andrews 2014-03-03 14:17:00 -08:00 committed by Felipe Zimmerle
parent 27dd513ab6
commit dda91f1689
4 changed files with 19 additions and 1 deletions

View File

@ -67,6 +67,10 @@ class REQUEST_STORED_CONTEXT : public IHttpStoredContext
{ {
modsecFinishRequest(m_pRequestRec); modsecFinishRequest(m_pRequestRec);
m_pRequestRec = NULL; m_pRequestRec = NULL;
}
if(m_pConnRec != NULL)
{
modsecFinishConnection(m_pConnRec);
m_pConnRec = NULL; m_pConnRec = NULL;
} }
} }

View File

@ -1356,6 +1356,10 @@ ngx_http_modsecurity_cleanup(void *data)
if (ctx->req != NULL) { if (ctx->req != NULL) {
(void) modsecFinishRequest(ctx->req); (void) modsecFinishRequest(ctx->req);
} }
if (ctx->connection != NULL) {
(void) modsecFinishConnection(ctx->connection);
}
} }
static char * static char *

View File

@ -654,11 +654,20 @@ int modsecFinishRequest(request_rec *r) {
// make sure you cleanup before calling apr_terminate() // make sure you cleanup before calling apr_terminate()
// otherwise double-free might occur, because of the request body pool cleanup function // otherwise double-free might occur, because of the request body pool cleanup function
// //
apr_pool_destroy(r->connection->pool); apr_pool_destroy(r->pool);
return DECLINED; return DECLINED;
} }
// destroy only the connection pool
int modsecFinishConnection(conn_rec *c)
{
apr_pool_destroy(c->pool);
}
void modsecSetLogHook(void *obj, void (*hook)(void *obj, int level, char *str)) { void modsecSetLogHook(void *obj, void (*hook)(void *obj, int level, char *str)) {
modsecLogObj = obj; modsecLogObj = obj;
modsecLogHook = hook; modsecLogHook = hook;

View File

@ -58,6 +58,7 @@ void modsecInitProcess();
conn_rec *modsecNewConnection(); conn_rec *modsecNewConnection();
void modsecProcessConnection(conn_rec *c); void modsecProcessConnection(conn_rec *c);
int modsecFinishConnection(conn_rec *c);
request_rec *modsecNewRequest(conn_rec *connection, directory_config *config); request_rec *modsecNewRequest(conn_rec *connection, directory_config *config);