Latest update - 9207
This commit is contained in:
@@ -170,6 +170,8 @@ ngx_http_copy_aio_handler(ngx_output_chain_ctx_t *ctx, ngx_file_t *file)
|
||||
file->aio->data = r;
|
||||
file->aio->handler = ngx_http_copy_aio_event_handler;
|
||||
|
||||
ngx_add_timer(&file->aio->event, 60000);
|
||||
|
||||
r->main->blocked++;
|
||||
r->aio = 1;
|
||||
ctx->aio = 1;
|
||||
@@ -192,12 +194,32 @@ ngx_http_copy_aio_event_handler(ngx_event_t *ev)
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
||||
"http aio: \"%V?%V\"", &r->uri, &r->args);
|
||||
|
||||
if (ev->timedout) {
|
||||
ngx_log_error(NGX_LOG_ALERT, c->log, 0,
|
||||
"aio operation took too long");
|
||||
ev->timedout = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ev->timer_set) {
|
||||
ngx_del_timer(ev);
|
||||
}
|
||||
|
||||
r->main->blocked--;
|
||||
r->aio = 0;
|
||||
|
||||
r->write_event_handler(r);
|
||||
if (r->main->terminated) {
|
||||
/*
|
||||
* trigger connection event handler if the request was
|
||||
* terminated
|
||||
*/
|
||||
|
||||
ngx_http_run_posted_requests(c);
|
||||
c->write->handler(c->write);
|
||||
|
||||
} else {
|
||||
r->write_event_handler(r);
|
||||
ngx_http_run_posted_requests(c);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -264,6 +286,8 @@ ngx_http_copy_thread_handler(ngx_thread_task_t *task, ngx_file_t *file)
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
ngx_add_timer(&task->event, 60000);
|
||||
|
||||
r->main->blocked++;
|
||||
r->aio = 1;
|
||||
|
||||
@@ -288,6 +312,17 @@ ngx_http_copy_thread_event_handler(ngx_event_t *ev)
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
||||
"http thread: \"%V?%V\"", &r->uri, &r->args);
|
||||
|
||||
if (ev->timedout) {
|
||||
ngx_log_error(NGX_LOG_ALERT, c->log, 0,
|
||||
"thread operation took too long");
|
||||
ev->timedout = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ev->timer_set) {
|
||||
ngx_del_timer(ev);
|
||||
}
|
||||
|
||||
r->main->blocked--;
|
||||
r->aio = 0;
|
||||
|
||||
@@ -305,11 +340,11 @@ ngx_http_copy_thread_event_handler(ngx_event_t *ev)
|
||||
|
||||
#endif
|
||||
|
||||
if (r->done) {
|
||||
if (r->done || r->main->terminated) {
|
||||
/*
|
||||
* trigger connection event handler if the subrequest was
|
||||
* already finalized; this can happen if the handler is used
|
||||
* for sendfile() in threads
|
||||
* already finalized (this can happen if the handler is used
|
||||
* for sendfile() in threads), or if the request was terminated
|
||||
*/
|
||||
|
||||
c->write->handler(c->write);
|
||||
|
||||
@@ -3961,7 +3961,7 @@ ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
|
||||
ngx_str_t *value, size;
|
||||
ngx_url_t u;
|
||||
ngx_uint_t n, i;
|
||||
ngx_uint_t n, i, backlog;
|
||||
ngx_http_listen_opt_t lsopt;
|
||||
|
||||
cscf->listen = 1;
|
||||
@@ -4000,6 +4000,8 @@ ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
lsopt.ipv6only = 1;
|
||||
#endif
|
||||
|
||||
backlog = 0;
|
||||
|
||||
for (n = 2; n < cf->args->nelts; n++) {
|
||||
|
||||
if (ngx_strcmp(value[n].data, "default_server") == 0
|
||||
@@ -4058,6 +4060,8 @@ ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
backlog = 1;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -4305,9 +4309,29 @@ ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
#if (NGX_HTTP_V3)
|
||||
|
||||
if (lsopt.quic) {
|
||||
#if (NGX_HAVE_TCP_FASTOPEN)
|
||||
if (lsopt.fastopen != -1) {
|
||||
return "\"fastopen\" parameter is incompatible with \"quic\"";
|
||||
}
|
||||
#endif
|
||||
|
||||
if (backlog) {
|
||||
return "\"backlog\" parameter is incompatible with \"quic\"";
|
||||
}
|
||||
|
||||
#if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
|
||||
if (lsopt.accept_filter) {
|
||||
return "\"accept_filter\" parameter is incompatible with \"quic\"";
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
|
||||
if (lsopt.deferred_accept) {
|
||||
return "\"deferred\" parameter is incompatible with \"quic\"";
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (NGX_HTTP_SSL)
|
||||
if (lsopt.ssl) {
|
||||
return "\"ssl\" parameter is incompatible with \"quic\"";
|
||||
@@ -4320,13 +4344,15 @@ ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (lsopt.so_keepalive) {
|
||||
return "\"so_keepalive\" parameter is incompatible with \"quic\"";
|
||||
}
|
||||
|
||||
if (lsopt.proxy_protocol) {
|
||||
return "\"proxy_protocol\" parameter is incompatible with \"quic\"";
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
for (n = 0; n < u.naddrs; n++) {
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
static ngx_int_t ngx_http_file_cache_lock(ngx_http_request_t *r,
|
||||
ngx_http_cache_t *c);
|
||||
static void ngx_http_file_cache_lock_wait_handler(ngx_event_t *ev);
|
||||
static void ngx_http_file_cache_lock_wait(ngx_http_request_t *r,
|
||||
static ngx_int_t ngx_http_file_cache_lock_wait(ngx_http_request_t *r,
|
||||
ngx_http_cache_t *c);
|
||||
static ngx_int_t ngx_http_file_cache_read(ngx_http_request_t *r,
|
||||
ngx_http_cache_t *c);
|
||||
@@ -463,6 +463,7 @@ ngx_http_file_cache_lock(ngx_http_request_t *r, ngx_http_cache_t *c)
|
||||
static void
|
||||
ngx_http_file_cache_lock_wait_handler(ngx_event_t *ev)
|
||||
{
|
||||
ngx_int_t rc;
|
||||
ngx_connection_t *c;
|
||||
ngx_http_request_t *r;
|
||||
|
||||
@@ -474,13 +475,31 @@ ngx_http_file_cache_lock_wait_handler(ngx_event_t *ev)
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
||||
"http file cache wait: \"%V?%V\"", &r->uri, &r->args);
|
||||
|
||||
ngx_http_file_cache_lock_wait(r, r->cache);
|
||||
rc = ngx_http_file_cache_lock_wait(r, r->cache);
|
||||
|
||||
ngx_http_run_posted_requests(c);
|
||||
if (rc == NGX_AGAIN) {
|
||||
return;
|
||||
}
|
||||
|
||||
r->cache->waiting = 0;
|
||||
r->main->blocked--;
|
||||
|
||||
if (r->main->terminated) {
|
||||
/*
|
||||
* trigger connection event handler if the request was
|
||||
* terminated
|
||||
*/
|
||||
|
||||
c->write->handler(c->write);
|
||||
|
||||
} else {
|
||||
r->write_event_handler(r);
|
||||
ngx_http_run_posted_requests(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
static ngx_int_t
|
||||
ngx_http_file_cache_lock_wait(ngx_http_request_t *r, ngx_http_cache_t *c)
|
||||
{
|
||||
ngx_uint_t wait;
|
||||
@@ -495,7 +514,7 @@ ngx_http_file_cache_lock_wait(ngx_http_request_t *r, ngx_http_cache_t *c)
|
||||
ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
|
||||
"cache lock timeout");
|
||||
c->lock_timeout = 0;
|
||||
goto wakeup;
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
cache = c->file_cache;
|
||||
@@ -513,14 +532,10 @@ ngx_http_file_cache_lock_wait(ngx_http_request_t *r, ngx_http_cache_t *c)
|
||||
|
||||
if (wait) {
|
||||
ngx_add_timer(&c->wait_event, (timer > 500) ? 500 : timer);
|
||||
return;
|
||||
return NGX_AGAIN;
|
||||
}
|
||||
|
||||
wakeup:
|
||||
|
||||
c->waiting = 0;
|
||||
r->main->blocked--;
|
||||
r->write_event_handler(r);
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -690,6 +705,8 @@ ngx_http_file_cache_aio_read(ngx_http_request_t *r, ngx_http_cache_t *c)
|
||||
c->file.aio->data = r;
|
||||
c->file.aio->handler = ngx_http_cache_aio_event_handler;
|
||||
|
||||
ngx_add_timer(&c->file.aio->event, 60000);
|
||||
|
||||
r->main->blocked++;
|
||||
r->aio = 1;
|
||||
|
||||
@@ -737,12 +754,32 @@ ngx_http_cache_aio_event_handler(ngx_event_t *ev)
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
||||
"http file cache aio: \"%V?%V\"", &r->uri, &r->args);
|
||||
|
||||
if (ev->timedout) {
|
||||
ngx_log_error(NGX_LOG_ALERT, c->log, 0,
|
||||
"aio operation took too long");
|
||||
ev->timedout = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ev->timer_set) {
|
||||
ngx_del_timer(ev);
|
||||
}
|
||||
|
||||
r->main->blocked--;
|
||||
r->aio = 0;
|
||||
|
||||
r->write_event_handler(r);
|
||||
if (r->main->terminated) {
|
||||
/*
|
||||
* trigger connection event handler if the request was
|
||||
* terminated
|
||||
*/
|
||||
|
||||
ngx_http_run_posted_requests(c);
|
||||
c->write->handler(c->write);
|
||||
|
||||
} else {
|
||||
r->write_event_handler(r);
|
||||
ngx_http_run_posted_requests(c);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -786,6 +823,8 @@ ngx_http_cache_thread_handler(ngx_thread_task_t *task, ngx_file_t *file)
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
ngx_add_timer(&task->event, 60000);
|
||||
|
||||
r->main->blocked++;
|
||||
r->aio = 1;
|
||||
|
||||
@@ -807,12 +846,32 @@ ngx_http_cache_thread_event_handler(ngx_event_t *ev)
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
||||
"http file cache thread: \"%V?%V\"", &r->uri, &r->args);
|
||||
|
||||
if (ev->timedout) {
|
||||
ngx_log_error(NGX_LOG_ALERT, c->log, 0,
|
||||
"thread operation took too long");
|
||||
ev->timedout = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ev->timer_set) {
|
||||
ngx_del_timer(ev);
|
||||
}
|
||||
|
||||
r->main->blocked--;
|
||||
r->aio = 0;
|
||||
|
||||
r->write_event_handler(r);
|
||||
if (r->main->terminated) {
|
||||
/*
|
||||
* trigger connection event handler if the request was
|
||||
* terminated
|
||||
*/
|
||||
|
||||
ngx_http_run_posted_requests(c);
|
||||
c->write->handler(c->write);
|
||||
|
||||
} else {
|
||||
r->write_event_handler(r);
|
||||
ngx_http_run_posted_requests(c);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2694,6 +2694,8 @@ ngx_http_terminate_request(ngx_http_request_t *r, ngx_int_t rc)
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||
"http terminate request count:%d", mr->count);
|
||||
|
||||
mr->terminated = 1;
|
||||
|
||||
if (rc > 0 && (mr->headers_out.status == 0 || mr->connection->sent == 0)) {
|
||||
mr->headers_out.status = rc;
|
||||
}
|
||||
@@ -2716,8 +2718,11 @@ ngx_http_terminate_request(ngx_http_request_t *r, ngx_int_t rc)
|
||||
if (mr->write_event_handler) {
|
||||
|
||||
if (mr->blocked) {
|
||||
r = r->connection->data;
|
||||
|
||||
r->connection->error = 1;
|
||||
r->write_event_handler = ngx_http_request_finalizer;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -550,6 +550,7 @@ struct ngx_http_request_s {
|
||||
unsigned root_tested:1;
|
||||
unsigned done:1;
|
||||
unsigned logged:1;
|
||||
unsigned terminated:1;
|
||||
|
||||
unsigned buffered:4;
|
||||
|
||||
|
||||
@@ -3949,6 +3949,8 @@ ngx_http_upstream_thread_handler(ngx_thread_task_t *task, ngx_file_t *file)
|
||||
r->aio = 1;
|
||||
p->aio = 1;
|
||||
|
||||
ngx_add_timer(&task->event, 60000);
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
@@ -3967,6 +3969,17 @@ ngx_http_upstream_thread_event_handler(ngx_event_t *ev)
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
||||
"http upstream thread: \"%V?%V\"", &r->uri, &r->args);
|
||||
|
||||
if (ev->timedout) {
|
||||
ngx_log_error(NGX_LOG_ALERT, c->log, 0,
|
||||
"thread operation took too long");
|
||||
ev->timedout = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ev->timer_set) {
|
||||
ngx_del_timer(ev);
|
||||
}
|
||||
|
||||
r->main->blocked--;
|
||||
r->aio = 0;
|
||||
|
||||
@@ -3984,11 +3997,11 @@ ngx_http_upstream_thread_event_handler(ngx_event_t *ev)
|
||||
|
||||
#endif
|
||||
|
||||
if (r->done) {
|
||||
if (r->done || r->main->terminated) {
|
||||
/*
|
||||
* trigger connection event handler if the subrequest was
|
||||
* already finalized; this can happen if the handler is used
|
||||
* for sendfile() in threads
|
||||
* already finalized (this can happen if the handler is used
|
||||
* for sendfile() in threads), or if the request was terminated
|
||||
*/
|
||||
|
||||
c->write->handler(c->write);
|
||||
@@ -4561,6 +4574,10 @@ ngx_http_upstream_finalize_request(ngx_http_request_t *r,
|
||||
|
||||
u->peer.connection = NULL;
|
||||
|
||||
if (u->pipe) {
|
||||
u->pipe->upstream = NULL;
|
||||
}
|
||||
|
||||
if (u->pipe && u->pipe->temp_file) {
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||
"http upstream temp fd: %d",
|
||||
|
||||
Reference in New Issue
Block a user