Welcome! Log In Create A New Profile

Advanced

Re: sendfile() failed (9: Bad file descriptor) while sending request to upstream

Maxim Dounin
August 12, 2010 08:24AM
Hello!

On Thu, Aug 12, 2010 at 07:00:39AM -0400, john2do wrote:

> nginx/0.7.65
> имеем в логах такого рода ошибки.
>
> sendfile() failed (9: Bad file descriptor) while sending request to
> upstream, client: x.x.x.x, server: foo.ru, request: "POST
> /edit/19067.php HTTP/1.1", subrequest: "/service/cache.php", upstream:
> "http://10.0.1.42:8200/service/cache.php?method=ssi&cacheid=4409", host:
> "foo.ru", referrer: "http://foo.ru/edit/19067.php"

Если тело запроса буферезировано в файл, то после первого
успешного proxy_pass оный файл удаляется, 0.3.3+:

*) Bugfix: a temporary file with client request body now is removed
just after the response header was transferred to a client.

Соответственно для подзапросов *необходимо* запрещать передачу
body через proxy_pass_request_body off; (и не забывать при этом
proxy_set_header Content-Length 0;).

Known issue. Если не удалять совсем (точнее, удалять только по
завершению запроса) - место в client temp расходуется без нужды, а
удалять с учётом возможных ssi и т.п. - получается дикий layering
violation. Хорошее решение - приветствуется.

Плохое решение - не удалять совсем, как-то так:

--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -2030,11 +2030,6 @@ ngx_http_upstream_send_response(ngx_http

u->header_sent = 1;

- if (r->request_body && r->request_body->temp_file) {
- ngx_pool_run_cleanup_file(r->pool, r->request_body->temp_file->file.fd);
- r->request_body->temp_file->file.fd = NGX_INVALID_FILE;
- }
-
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);

if (!u->buffering) {


Maxim Dounin

_______________________________________________
nginx-ru mailing list
nginx-ru@nginx.org
http://nginx.org/mailman/listinfo/nginx-ru
Subject Author Posted

sendfile() failed (9: Bad file descriptor) while sending request to upstream

john2do August 12, 2010 07:00AM

Re: sendfile() failed (9: Bad file descriptor) while sending request to upstream

Maxim Dounin August 12, 2010 08:24AM

Re: sendfile() failed (9: Bad file descriptor) while sending request to upstream

papajoe February 22, 2018 08:12AM

Re: sendfile() failed (9: Bad file descriptor) while sending request to upstream

Maxim Dounin February 22, 2018 12:08PM

Re: sendfile() failed (9: Bad file descriptor) while sending request to upstream

papajoe February 23, 2018 02:36PM

Re: sendfile() failed (9: Bad file descriptor) while sending request to upstream

john2do August 12, 2010 11:09PM

Re: sendfile() failed (9: Bad file descriptor) while sending request to upstream

john2do August 12, 2010 11:37PM

Re: sendfile() failed (9: Bad file descriptor) while sending request to upstream

john2do August 13, 2010 02:07AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 298
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