From ac3efbbea8cd303c9f5fc426717ec05909cabac3 Mon Sep 17 00:00:00 2001 From: "agentzh (Yichun Zhang)" Date: Wed, 5 Sep 2012 15:11:52 -0700 Subject: [PATCH] added the nonbuffered-upstream-truncation patch for nginx 1.2.3 to make ngx_http_upstream provide a way in the context of a subrequest to signal the parent of errors when upstream data truncation happens. thanks Bryan Alger for reporting this issue. --- ....2.3-nonbuffered-upstream-truncation.patch | 28 +++++++++++++++++++ util/mirror-tarballs | 3 ++ 2 files changed, 31 insertions(+) create mode 100644 patches/nginx-1.2.3-nonbuffered-upstream-truncation.patch diff --git a/patches/nginx-1.2.3-nonbuffered-upstream-truncation.patch b/patches/nginx-1.2.3-nonbuffered-upstream-truncation.patch new file mode 100644 index 0000000..ce70f82 --- /dev/null +++ b/patches/nginx-1.2.3-nonbuffered-upstream-truncation.patch @@ -0,0 +1,28 @@ +--- nginx-1.2.3/src/http/ngx_http_upstream.c 2012-09-05 14:39:33.234197951 -0700 ++++ nginx-1.2.3-patched/src/http/ngx_http_upstream.c 2012-09-05 14:39:24.504183525 -0700 +@@ -2384,6 +2384,7 @@ + c->log->action = "reading upstream"; + + if (c->read->timedout) { ++ r->headers_out.status = NGX_HTTP_GATEWAY_TIME_OUT; + ngx_connection_error(c, NGX_ETIMEDOUT, "upstream timed out"); + ngx_http_upstream_finalize_request(r, u, 0); + return; +@@ -2431,10 +2432,13 @@ + + if (u->busy_bufs == NULL) { + +- if (u->length == 0 +- || upstream->read->eof +- || upstream->read->error) +- { ++ if (u->length == 0) { ++ ngx_http_upstream_finalize_request(r, u, 0); ++ return; ++ } ++ ++ if (upstream->read->eof || upstream->read->error) { ++ r->headers_out.status = NGX_HTTP_BAD_GATEWAY; + ngx_http_upstream_finalize_request(r, u, 0); + return; + } diff --git a/util/mirror-tarballs b/util/mirror-tarballs index 47e4cd6..010423c 100755 --- a/util/mirror-tarballs +++ b/util/mirror-tarballs @@ -93,6 +93,9 @@ fi echo applying location_if_inherits_proxy.patch ... patch -p1 < $root/patches/nginx-$main_ver-location_if_inherits_proxy.patch +echo applying nonbuffered-upstream-truncation.patch ... +patch -p1 < $root/patches/nginx-$main_ver-nonbuffered-upstream-truncation.patch + echo applying dtrace.patch ... patch -p1 < $root/patches/nginx-$main_ver-dtrace.patch