@@ -75,6 +75,8 @@ static ngx_int_t ngx_http_modsecurity_pass_to_backend(ngx_http_request_t *r);
75
75
76
76
static int ngx_http_modsecurity_drop_action (request_rec * r );
77
77
78
+ static void ngx_http_modsecurity_cleanup (void * data );
79
+
78
80
/* command handled by the module */
79
81
static ngx_command_t ngx_http_modsecurity_commands [] = {
80
82
{ ngx_string ("ModSecurityConfig" ),
@@ -451,6 +453,7 @@ ngx_http_modsecurity_handler(ngx_http_request_t *r)
451
453
ngx_uint_t i ;
452
454
ngx_int_t rc ;
453
455
void * * loc_conf ;
456
+ ngx_pool_cleanup_t * cln ;
454
457
455
458
ngx_log_debug0 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 , "modSecurity: handler" );
456
459
@@ -538,6 +541,14 @@ ngx_http_modsecurity_handler(ngx_http_request_t *r)
538
541
apr_table_setn (ctx -> req -> subprocess_env , "UNIQUE_ID" , "12345" );
539
542
/* actually, we need ctx only for POST request body handling - don't like this part */
540
543
apr_table_setn (ctx -> req -> notes , NOTE_NGINX_REQUEST_CTX , (const char * ) ctx );
544
+
545
+ /* add cleanup */
546
+ cln = ngx_pool_cleanup_add (r -> pool , 0 );
547
+ if (cln == NULL ) {
548
+ return NGX_ERROR ;
549
+ }
550
+ cln -> data = ctx ;
551
+ cln -> handler = ngx_http_modsecurity_cleanup ;
541
552
}
542
553
543
554
// r->keepalive = 0;
@@ -600,6 +611,16 @@ ngx_http_modsecurity_handler(ngx_http_request_t *r)
600
611
return rc ;
601
612
}
602
613
614
+ static void
615
+ ngx_http_modsecurity_cleanup (void * data )
616
+ {
617
+ ngx_http_modsecurity_ctx_t * ctx = data ;
618
+
619
+ if (ctx -> req != NULL ) {
620
+ (void ) modsecFinishRequest (ctx -> req );
621
+ }
622
+ }
623
+
603
624
604
625
static void
605
626
ngx_http_modsecurity_request_body_handler (ngx_http_request_t * r )
0 commit comments