Mercurial > hg > nginx-quic
diff src/http/ngx_http_upstream.c @ 3245:61962127b166 stable-0.7
merge r3001, r3007, r3013:
fix variuos segfaults:
*) fix segfault if 400 or 414 errors are handled intricately
*) ngx_http_upstream_create() to cleanup the previous upstream after
internal redirect
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 26 Oct 2009 17:09:27 +0000 |
parents | 8254055b6693 |
children | eb555a9a57d4 |
line wrap: on
line diff
--- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -354,6 +354,35 @@ ngx_conf_bitmask_t ngx_http_upstream_ca }; +ngx_int_t +ngx_http_upstream_create(ngx_http_request_t *r) +{ + ngx_http_upstream_t *u; + + u = r->upstream; + + if (u && u->cleanup) { + ngx_http_upstream_cleanup(r); + *u->cleanup = NULL; + } + + u = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_t)); + if (u == NULL) { + return NGX_ERROR; + } + + r->upstream = u; + + u->peer.log = r->connection->log; + u->peer.log_error = NGX_ERROR_ERR; +#if (NGX_THREADS) + u->peer.lock = &r->connection->lock; +#endif + + return NGX_OK; +} + + void ngx_http_upstream_init(ngx_http_request_t *r) { @@ -2864,7 +2893,7 @@ ngx_http_upstream_finalize_request(ngx_h #if (NGX_HTTP_CACHE) - if (u->cacheable) { + if (u->cacheable && r->cache) { time_t valid; ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,