Welcome! Log In Create A New Profile

Advanced

[PATCH 10 of 15] Tempfiles: Setup event handlers in ngx_http_upstream.c

Jiří Setnička via nginx-devel
January 28, 2022 11:56AM
# HG changeset patch
# User Jiří Setnička <jiri.setnicka@cdn77.com>
# Date 1643385660 -3600
# Fri Jan 28 17:01:00 2022 +0100
# Node ID bd12e8ba1af2005260e68a410e3c8927a88dac1a
# Parent 24453fd1ce204f361748c32e3c271d9e6fc7c9eb
Tempfiles: Setup event handlers in ngx_http_upstream.c
Introduced in the previous commits the file cache could serve multiple
clients from the currently downloading tempfiles. This is achieved by
repeated execution of ngx_http_file_cache_send and related functions.

Each run is performed by executing ngx_http_upstream_init_request,
invoked by either write event or by tempfiles timer.

diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -576,10 +576,12 @@ ngx_http_upstream_init_request(ngx_http_

if (rc == NGX_BUSY) {
r->write_event_handler = ngx_http_upstream_init_request;
+ r->read_event_handler = ngx_http_test_reading;
return;
}

r->write_event_handler = ngx_http_request_empty_handler;
+ r->read_event_handler = ngx_http_block_reading;

if (rc == NGX_ERROR) {
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
@@ -589,6 +591,15 @@ ngx_http_upstream_init_request(ngx_http_
if (rc == NGX_OK) {
rc = ngx_http_upstream_cache_send(r, u);

+ if (rc == NGX_BUSY) {
+ r->write_event_handler = ngx_http_upstream_init_request;
+ r->read_event_handler = ngx_http_test_reading;
+ return;
+ }
+
+ r->write_event_handler = ngx_http_request_empty_handler;
+ r->read_event_handler = ngx_http_block_reading;
+
if (rc == NGX_DONE) {
return;
}
@@ -1088,6 +1099,10 @@ ngx_http_upstream_cache_send(ngx_http_re
return NGX_ERROR;
}

+ if (r->header_sent) {
+ return ngx_http_cache_send(r);
+ }
+
rc = u->process_header(r);

if (rc == NGX_OK) {
@@ -2984,7 +2999,11 @@ ngx_http_upstream_send_response(ngx_http
ngx_connection_t *c;
ngx_http_core_loc_conf_t *clcf;

- rc = ngx_http_send_header(r);
+ if (r->header_sent) {
+ rc = NGX_OK;
+ } else {
+ rc = ngx_http_send_header(r);
+ }

if (rc == NGX_ERROR || rc > NGX_OK || r->post_action) {
ngx_http_upstream_finalize_request(r, u, rc);
_______________________________________________
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
Subject Author Views Posted

[PATCH 00 of 15] Serve all requests from single tempfile

Jiří Setnička via nginx-devel 468 January 28, 2022 11:36AM

[PATCH 01 of 15] ngx core - obtain number appended to the temp file name

Jiří Setnička via nginx-devel 133 January 28, 2022 11:38AM

[PATCH 02 of 15] ngx core - ensure that tempfile number never be 0

Jiří Setnička via nginx-devel 141 January 28, 2022 11:40AM

[PATCH 03 of 15] Cache: Shared memory for tempfile nodes

Jiří Setnička via nginx-devel 280 January 28, 2022 11:42AM

[PATCH 04 of 15] Cache: tf_node for tracking opened tempfile

Jiří Setnička via nginx-devel 130 January 28, 2022 11:44AM

[PATCH 05 of 15] http upstream & file_cache: store temp file number and length in tf_node

Jiří Setnička via nginx-devel 142 January 28, 2022 11:46AM

[PATCH 07 of 15] Tempfiles: Wait handlers

Jiří Setnička via nginx-devel 122 January 28, 2022 11:48AM

[PATCH 06 of 15] Configuration for tempfiles serving

Jiří Setnička via nginx-devel 163 January 28, 2022 11:50AM

[PATCH 09 of 15] Tempfiles: Sending data from tempfile

Jiří Setnička via nginx-devel 127 January 28, 2022 11:52AM

[PATCH 08 of 15] Tempfiles: Mechanism of opening tempfiles used for serving paralell requests

Jiří Setnička via nginx-devel 131 January 28, 2022 11:54AM

[PATCH 10 of 15] Tempfiles: Setup event handlers in ngx_http_upstream.c

Jiří Setnička via nginx-devel 144 January 28, 2022 11:56AM

[PATCH 11 of 15] Tempfiles: reset c->body_start when updating a tempfile

Jiří Setnička via nginx-devel 149 January 28, 2022 11:58AM

[PATCH 12 of 15] Tempfiles: Expired tempfiles

Jiří Setnička via nginx-devel 153 January 28, 2022 12:00PM

[PATCH 13 of 15] Tempfiles: Skip cached file if there is already newer tempfile

Jiří Setnička via nginx-devel 248 January 28, 2022 12:02PM

Re: [PATCH 13 of 15] Tempfiles: Skip cached file if there is already newer tempfile

Vadim Fedorenko 151 January 30, 2022 07:38PM

Re: [PATCH 13 of 15] Tempfiles: Skip cached file if there is already newer tempfile

Jiří Setnička via nginx-devel 142 February 07, 2022 06:22AM

[PATCH 14 of 15] Tempfiles: Set send_timeout inside ngx_http_cache_send

Jiří Setnička via nginx-devel 158 January 28, 2022 12:04PM

[PATCH 15 of 15] Use cache status UPDATING when serving from tempfile

Jiří Setnička via nginx-devel 131 January 28, 2022 12:06PM

Re: [PATCH 00 of 15] Serve all requests from single tempfile

Jiří Setnička via nginx-devel 127 February 07, 2022 06:18AM

Re: [PATCH 00 of 15] Serve all requests from single tempfile

Roman Arutyunyan 143 February 07, 2022 06:32AM

Re: [PATCH 00 of 15] Serve all requests from single tempfile

Jiří Setnička via nginx-devel 165 February 07, 2022 07:30AM

Re: [PATCH 00 of 15] Serve all requests from single tempfile

Roman Arutyunyan 180 February 08, 2022 06:20AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 224
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready