@@ -103,11 +103,7 @@ ngx_int_t ngx_http_redirectionio_headers_filter(ngx_http_request_t *r) {
103103
104104 // Check connection
105105 if (ctx -> connection_error ) {
106- ngx_http_redirectionio_release_resource (conf -> connection_pool , ctx -> resource , 1 );
107-
108- ctx -> wait_for_connection = 0 ;
109- ctx -> resource = NULL ;
110- ctx -> connection_error = 0 ;
106+ ngx_http_redirectionio_release_resource (conf -> connection_pool , ctx , 1 );
111107
112108 return ngx_http_next_header_filter (r );
113109 }
@@ -182,11 +178,7 @@ ngx_int_t ngx_http_redirectionio_body_filter(ngx_http_request_t *r, ngx_chain_t
182178
183179 // Check connection
184180 if (ctx -> connection_error ) {
185- ngx_http_redirectionio_release_resource (conf -> connection_pool , ctx -> resource , 1 );
186-
187- ctx -> wait_for_connection = 0 ;
188- ctx -> resource = NULL ;
189- ctx -> connection_error = 0 ;
181+ ngx_http_redirectionio_release_resource (conf -> connection_pool , ctx , 1 );
190182
191183 return ngx_http_next_body_filter (r , ctx -> body_buffer );
192184 }
@@ -270,7 +262,7 @@ static void ngx_http_redirectionio_read_filter_headers_handler(ngx_event_t *rev,
270262 ctx -> wait_for_header_filtering = 0 ;
271263
272264 if (json == NULL ) {
273- ngx_http_redirectionio_release_resource (conf -> connection_pool , ctx -> resource , 1 );
265+ ngx_http_redirectionio_release_resource (conf -> connection_pool , ctx , 1 );
274266 ngx_http_redirectionio_finalize_request (r , ctx );
275267
276268 return ;
@@ -279,7 +271,7 @@ static void ngx_http_redirectionio_read_filter_headers_handler(ngx_event_t *rev,
279271 headers = cJSON_GetObjectItem (json , "headers" );
280272
281273 if (headers == NULL || headers -> type != cJSON_Array ) {
282- ngx_http_redirectionio_release_resource (conf -> connection_pool , ctx -> resource , 1 );
274+ ngx_http_redirectionio_release_resource (conf -> connection_pool , ctx , 1 );
283275 ngx_http_redirectionio_finalize_request (r , ctx );
284276
285277 return ;
@@ -332,9 +324,7 @@ static void ngx_http_redirectionio_read_filter_headers_handler(ngx_event_t *rev,
332324 h -> value .len = strlen (value -> valuestring );
333325 }
334326
335- ngx_http_redirectionio_release_resource (conf -> connection_pool , ctx -> resource , 0 );
336- ctx -> wait_for_connection = 0 ;
337- ctx -> resource = NULL ;
327+ ngx_http_redirectionio_release_resource (conf -> connection_pool , ctx , 0 );
338328
339329 ngx_http_redirectionio_finalize_request (r , ctx );
340330}
@@ -359,8 +349,7 @@ static void ngx_http_redirectionio_read_filter_body_handler(ngx_event_t *rev, u_
359349 // If buffer is last or errored -> send a last empty buffer, finalize request and release resource
360350 if (buffer_size < 0 ) {
361351 if (ctx -> resource != NULL ) {
362- ngx_http_redirectionio_release_resource (conf -> connection_pool , ctx -> resource , (buffer_size == -1 ) ? 0 : 1 );
363- ctx -> resource = NULL ;
352+ ngx_http_redirectionio_release_resource (conf -> connection_pool , ctx , (buffer_size == -1 ) ? 0 : 1 );
364353 }
365354
366355 new_chain = ngx_alloc_chain_link (r -> pool );
0 commit comments