comparison ngx_http_delay_module.c @ 2:aee676aa6c1f default tip

Fixed delaying subrequests. Similar to 7fcf209d40c8 in the limit_req module, we now set wev->delayed to avoid interference with other subrequests. With 903fb1ddc07f in nginx (wev->delayed handling moved to the connection event handler, nginx 1.11.13), it will be also possible to remove wev->timedout tests and wev->timedout / wev->delayed reset after the timer expiration. These are preserved for now to make the code compatible with older nginx versions.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 29 May 2017 18:28:58 +0300
parents 9777bf89da35
children
comparison
equal deleted inserted replaced
1:3cdd7ed86819 2:aee676aa6c1f
90 } 90 }
91 91
92 r->read_event_handler = ngx_http_test_reading; 92 r->read_event_handler = ngx_http_test_reading;
93 r->write_event_handler = ngx_http_delay_event_handler; 93 r->write_event_handler = ngx_http_delay_event_handler;
94 94
95 r->connection->write->delayed = 1;
95 ngx_add_timer(r->connection->write, dcf->delay); 96 ngx_add_timer(r->connection->write, dcf->delay);
96 97
97 ngx_http_set_ctx(r, (void *) 1, ngx_http_delay_module); 98 ngx_http_set_ctx(r, (void *) 1, ngx_http_delay_module);
98 99
99 return NGX_AGAIN; 100 return NGX_AGAIN;
108 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 109 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
109 "delay"); 110 "delay");
110 111
111 wev = r->connection->write; 112 wev = r->connection->write;
112 113
113 if (!wev->timedout) { 114 if (wev->delayed && !wev->timedout) {
114 115
115 if (ngx_handle_write_event(wev, 0) != NGX_OK) { 116 if (ngx_handle_write_event(wev, 0) != NGX_OK) {
116 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); 117 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
117 } 118 }
118 119
119 return; 120 return;
120 } 121 }
121 122
123 wev->delayed = 0;
122 wev->timedout = 0; 124 wev->timedout = 0;
123 125
124 if (ngx_handle_read_event(r->connection->read, 0) != NGX_OK) { 126 if (ngx_handle_read_event(r->connection->read, 0) != NGX_OK) {
125 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); 127 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
126 return; 128 return;