comparison src/http/modules/perl/ngx_http_perl_module.c @ 6961:903fb1ddc07f

Moved handling of wev->delayed to the connection event handler. With post_action or subrequests, it is possible that the timer set for wev->delayed will expire while the active subrequest write event handler is not ready to handle this. This results in request hangs as observed with limit_rate / sendfile_max_chunk and post_action (ticket #776) or subrequests (ticket #1228). Moving the handling to the connection event handler fixes the hangs observed, and also slightly simplifies the code.
author Maxim Dounin <mdounin@mdounin.ru>
date Sun, 02 Apr 2017 14:32:29 +0300
parents 1c5e5e5b008d
children 919a5c6c828c
comparison
equal deleted inserted replaced
6960:1c5e5e5b008d 6961:903fb1ddc07f
276 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 276 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
277 "perl sleep handler"); 277 "perl sleep handler");
278 278
279 wev = r->connection->write; 279 wev = r->connection->write;
280 280
281 if (wev->delayed && !wev->timedout) { 281 if (wev->delayed) {
282 282
283 if (ngx_handle_write_event(wev, 0) != NGX_OK) { 283 if (ngx_handle_write_event(wev, 0) != NGX_OK) {
284 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); 284 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
285 } 285 }
286 286
287 return; 287 return;
288 } 288 }
289
290 wev->delayed = 0;
291 wev->timedout = 0;
292 289
293 ngx_http_perl_handle_request(r); 290 ngx_http_perl_handle_request(r);
294 } 291 }
295 292
296 293