# HG changeset patch # User Jiří Setnička <jiri.setni...@cdn77.com> # Date 1643385660 -3600 # Fri Jan 28 17:01:00 2022 +0100 # Node ID 3cd1f04d933137153b0628819ccb251d1f57614b # Parent 5e64af4c94860cd5cf4b9af5a265d3a087e7b735 Tempfiles: Set send_timeout inside ngx_http_cache_send
diff --git a/src/http/ngx_http_file_cache.c b/src/http/ngx_http_file_cache.c --- a/src/http/ngx_http_file_cache.c +++ b/src/http/ngx_http_file_cache.c @@ -1953,9 +1953,10 @@ done: ngx_int_t ngx_http_cache_send(ngx_http_request_t *r) { - ngx_int_t rc; - ngx_event_t *wev; - ngx_http_cache_t *c; + ngx_int_t rc; + ngx_event_t *wev; + ngx_http_cache_t *c; + ngx_http_core_loc_conf_t *clcf; c = r->cache; @@ -1965,6 +1966,33 @@ ngx_http_cache_send(ngx_http_request_t * wev = r->connection->write; + clcf = ngx_http_get_module_loc_conf(r->main, ngx_http_core_module); + + if (wev->timedout) { + ngx_log_error(NGX_LOG_INFO, r->connection->log, NGX_ETIMEDOUT, + "client timed out"); + r->connection->timedout = 1; + + return NGX_HTTP_REQUEST_TIME_OUT; + } + + if (wev->delayed || r->aio) { + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, wev->log, 0, + "http writer delayed"); + + if (!wev->delayed) { + ngx_add_timer(wev, clcf->send_timeout); + } + + rc = ngx_handle_write_event(wev, clcf->send_lowat); + if (rc != NGX_OK) { + ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "handle write event error: %d", rc); + return rc; + } + + return NGX_BUSY; + } + ngx_shmtx_lock(&c->file_cache->shpool->mutex); c->length = c->tf_node->length; @@ -1978,6 +2006,14 @@ ngx_http_cache_send(ngx_http_request_t * } if (rc == NGX_AGAIN && !wev->ready) { + if (!wev->delayed) { + ngx_add_timer(wev, clcf->send_timeout); + } + + if (ngx_handle_write_event(wev, clcf->send_lowat) != NGX_OK) { + return NGX_ERROR; + } + return NGX_BUSY; /* epoll will wake us */ } _______________________________________________ nginx-devel mailing list -- nginx-devel@nginx.org To unsubscribe send an email to nginx-devel-le...@nginx.org