Welcome! Log In Create A New Profile

Advanced

[PATCH] ngx_upstream do not cleanup file buffers in subrequest

March 08, 2011 03:24PM
Hello,

Is it reasonable to add following check to not clean/discard fd in case if it's sub request?

I developed nginx module and when it started to use tmp buffers under load I had following error:

[alert] 29663#0: *45789 sendfile() failed (9: Bad file descriptor) while sending request to upstream, client: 10.1.24.14, server: hss, request: "POST

So that sub-request cleared file before main request reached it. Probably this bug should not appear if request body was discarded for sub request. But in case if you need request body for sub-request you should be sure that sub-request does not erases main request buffers.


-- src/http/ngx_http_upstream.c_orig 2011-03-08 08:01:20.000000000 -0800
+++ src/http/ngx_http_upstream.c 2011-03-08 08:01:41.000000000 -0800
@@ -2033,7 +2033,7 @@ ngx_http_upstream_send_response(ngx_http

u->header_sent = 1;

- if (r->request_body && r->request_body->temp_file) {
+ if (r->request_body && r->request_body->temp_file && r == r->main) {
ngx_pool_run_cleanup_file(r->pool, r->request_body->temp_file->file.fd);
r->request_body->temp_file->file.fd = NGX_INVALID_FILE;
}
Subject Author Posted

[PATCH] ngx_upstream do not cleanup file buffers in subrequest

magz March 08, 2011 03:24PM

Re: [PATCH] ngx_upstream do not cleanup file buffers in subrequest

Maxim Dounin March 09, 2011 06:20AM

Re: [PATCH] ngx_upstream do not cleanup file buffers in subrequest

magz March 09, 2011 01:46PM

Re: [PATCH] ngx_upstream do not cleanup file buffers in subrequest

magz March 09, 2011 02:22PM

Re: [PATCH] ngx_upstream do not cleanup file buffers in subrequest

magz March 09, 2011 02:28PM

Re: [PATCH] ngx_upstream do not cleanup file buffers in subrequest

Maxim Dounin March 09, 2011 02:04PM

Re: [PATCH] ngx_upstream do not cleanup file buffers in subrequest

magz March 09, 2011 09:55PM

Re: [PATCH] ngx_upstream do not cleanup file buffers in subrequest

Maxim Dounin March 09, 2011 07:32PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 154
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready