@@ -21,12 +21,6 @@ static apr_status_t redirectionio_read_string(redirectionio_connection *conn, ch
21
21
22
22
static apr_status_t redirectionio_send_protocol_header (redirectionio_connection * conn , const char * project_key , apr_uint16_t command , request_rec * r );
23
23
24
- static apr_status_t redirectionio_action_cleanup (void * action );
25
-
26
- static apr_status_t redirectionio_request_cleanup (void * request );
27
-
28
- static apr_status_t redirectionio_response_headers_cleanup (void * response_headers );
29
-
30
24
apr_status_t redirectionio_protocol_match (redirectionio_connection * conn , redirectionio_context * ctx , request_rec * r , const char * project_key ) {
31
25
apr_uint32_t alen ;
32
26
apr_status_t rv ;
@@ -92,8 +86,6 @@ apr_status_t redirectionio_protocol_match(redirectionio_connection *conn, redire
92
86
93
87
redirectionio_request_set_remote_addr (ctx -> request , r -> connection -> client_ip , config -> trusted_proxies );
94
88
95
- apr_pool_pre_cleanup_register (r -> pool , ctx -> request , redirectionio_request_cleanup );
96
-
97
89
// Serialize request
98
90
request_serialized = redirectionio_request_json_serialize (ctx -> request );
99
91
@@ -155,10 +147,6 @@ apr_status_t redirectionio_protocol_match(redirectionio_connection *conn, redire
155
147
156
148
// Unserialize action
157
149
ctx -> action = (struct REDIRECTIONIO_Action * )redirectionio_action_json_deserialize (action_serialized );
158
-
159
- if (ctx -> action != NULL ) {
160
- apr_pool_pre_cleanup_register (r -> pool , ctx -> action , redirectionio_action_cleanup );
161
- }
162
150
}
163
151
164
152
return APR_SUCCESS ;
@@ -259,7 +247,6 @@ apr_status_t redirectionio_protocol_send_filter_headers(redirectionio_context *c
259
247
return APR_SUCCESS ;
260
248
}
261
249
262
- apr_pool_pre_cleanup_register (r -> pool , ctx -> response_headers , redirectionio_response_headers_cleanup );
263
250
apr_table_clear (r -> headers_out );
264
251
265
252
while (first_header != NULL ) {
@@ -448,31 +435,38 @@ static apr_status_t redirectionio_send_protocol_header(redirectionio_connection
448
435
return APR_SUCCESS ;
449
436
}
450
437
451
- static apr_status_t redirectionio_action_cleanup (void * action ) {
452
- redirectionio_action_drop (action );
438
+ apr_status_t redirectionio_context_cleanup (void * context ) {
439
+ struct REDIRECTIONIO_HeaderMap * first_header , * tmp_header ;
440
+ redirectionio_context * ctx = (redirectionio_context * )context ;
453
441
454
- return APR_SUCCESS ;
455
- }
442
+ if (ctx -> request != NULL ) {
443
+ redirectionio_request_drop (ctx -> request );
444
+ }
456
445
457
- static apr_status_t redirectionio_request_cleanup (void * request ) {
458
- redirectionio_request_drop (request );
446
+ if (ctx -> action != NULL ) {
447
+ redirectionio_action_drop (ctx -> action );
448
+ ctx -> action = NULL ;
449
+ }
459
450
460
- return APR_SUCCESS ;
461
- }
451
+ if ( ctx -> response_headers != NULL ) {
452
+ first_header = ( struct REDIRECTIONIO_HeaderMap * ) ctx -> response_headers ;
462
453
463
- static apr_status_t redirectionio_response_headers_cleanup ( void * response_headers ) {
464
- struct REDIRECTIONIO_HeaderMap * first_header , * tmp_header ;
454
+ while ( first_header != NULL ) {
455
+ tmp_header = first_header -> next ;
465
456
466
- first_header = (struct REDIRECTIONIO_HeaderMap * )response_headers ;
457
+ free ((void * )first_header -> name );
458
+ free ((void * )first_header -> value );
459
+ free ((void * )first_header );
467
460
468
- while ( first_header != NULL ) {
469
- tmp_header = first_header -> next ;
461
+ first_header = tmp_header ;
462
+ }
470
463
471
- free ((void * )first_header -> name );
472
- free ((void * )first_header -> value );
473
- free ((void * )first_header );
464
+ ctx -> response_headers = NULL ;
465
+ }
474
466
475
- first_header = tmp_header ;
467
+ if (ctx -> body_filter != NULL ) {
468
+ redirectionio_action_body_filter_drop (ctx -> body_filter );
469
+ ctx -> body_filter = NULL ;
476
470
}
477
471
478
472
return APR_SUCCESS ;
0 commit comments