Mercurial > hg > nginx-vendor-1-0
diff src/http/ngx_http_upstream.c @ 486:6484cbba0222 NGINX_0_7_55
nginx 0.7.55
*) Bugfix: the http_XXX parameters in "proxy_cache_use_stale" and
"fastcgi_cache_use_stale" directives did not work.
*) Bugfix: fastcgi cache did not cache header only responses.
*) Bugfix: of "select() failed (9: Bad file descriptor)" error in
nginx/Unix and "select() failed (10022: ...)" error in nginx/Windows.
*) Bugfix: a segmentation fault might occur in worker process, if an
"debug_connection" directive was used; the bug had appeared in
0.7.54.
*) Bugfix: fix ngx_http_image_filter_module building errors.
*) Bugfix: the files bigger than 2G could not be transferred using
$r->sendfile.
Thanks to Maxim Dounin.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Wed, 06 May 2009 00:00:00 +0400 |
parents | ed5e10fb40fc |
children | 829f9a66a659 |
line wrap: on
line diff
--- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -768,6 +768,7 @@ ngx_http_upstream_check_broken_connectio int n; char buf[1]; ngx_err_t err; + ngx_int_t event; ngx_connection_t *c; ngx_http_upstream_t *u; @@ -779,10 +780,22 @@ ngx_http_upstream_check_broken_connectio u = r->upstream; if (c->error) { + if ((ngx_event_flags & NGX_USE_LEVEL_EVENT) && ev->active) { + + event = ev->write ? NGX_WRITE_EVENT : NGX_READ_EVENT; + + if (ngx_del_event(ev, event, 0) != NGX_OK) { + ngx_http_upstream_finalize_request(r, u, + NGX_HTTP_INTERNAL_SERVER_ERROR); + return; + } + } + if (!u->cacheable) { ngx_http_upstream_finalize_request(r, u, NGX_HTTP_CLIENT_CLOSED_REQUEST); } + return; } @@ -836,17 +849,15 @@ ngx_http_upstream_check_broken_connectio ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ev->log, err, "http upstream recv(): %d", n); - /* - * we do not need to disable the write event because - * that event has NGX_USE_CLEAR_EVENT type - */ - if (ev->write && (n >= 0 || err == NGX_EAGAIN)) { return; } if ((ngx_event_flags & NGX_USE_LEVEL_EVENT) && ev->active) { - if (ngx_del_event(ev, NGX_READ_EVENT, 0) == NGX_ERROR) { + + event = ev->write ? NGX_WRITE_EVENT : NGX_READ_EVENT; + + if (ngx_del_event(ev, event, 0) != NGX_OK) { ngx_http_upstream_finalize_request(r, u, NGX_HTTP_INTERNAL_SERVER_ERROR); return; @@ -1472,13 +1483,10 @@ ngx_http_upstream_process_header(ngx_htt static ngx_int_t ngx_http_upstream_test_next(ngx_http_request_t *r, ngx_http_upstream_t *u) { + ngx_int_t rc; ngx_uint_t status; ngx_http_upstream_next_t *un; - if (!(u->conf->next_upstream & NGX_HTTP_UPSTREAM_FT_STATUS)) { - return NGX_DECLINED; - } - status = u->headers_in.status_n; for (un = ngx_http_upstream_next_errors; un->status; un++) { @@ -1494,12 +1502,15 @@ ngx_http_upstream_test_next(ngx_http_req #if (NGX_HTTP_CACHE) - if (u->peer.tries == 0 - && u->stale_cache - && (u->conf->cache_use_stale & un->mask)) - { - ngx_http_upstream_finalize_request(r, u, - ngx_http_upstream_cache_send(r, u)); + if (u->stale_cache && (u->conf->cache_use_stale & un->mask)) { + + rc = u->reinit_request(r); + + if (rc == NGX_OK) { + rc = ngx_http_upstream_cache_send(r, u); + } + + ngx_http_upstream_finalize_request(r, u, rc); return NGX_OK; } @@ -2650,9 +2661,15 @@ ngx_http_upstream_next(ngx_http_request_ #if (NGX_HTTP_CACHE) if (u->stale_cache && (u->conf->cache_use_stale & ft_type)) { - - ngx_http_upstream_finalize_request(r, u, - ngx_http_upstream_cache_send(r, u)); + ngx_int_t rc; + + rc = u->reinit_request(r); + + if (rc == NGX_OK) { + rc = ngx_http_upstream_cache_send(r, u); + } + + ngx_http_upstream_finalize_request(r, u, rc); return; } #endif