comparison 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
comparison
equal deleted inserted replaced
3244:8b2d478de54b 3245:61962127b166
352 { ngx_string("POST"), NGX_HTTP_POST }, 352 { ngx_string("POST"), NGX_HTTP_POST },
353 { ngx_null_string, 0 } 353 { ngx_null_string, 0 }
354 }; 354 };
355 355
356 356
357 ngx_int_t
358 ngx_http_upstream_create(ngx_http_request_t *r)
359 {
360 ngx_http_upstream_t *u;
361
362 u = r->upstream;
363
364 if (u && u->cleanup) {
365 ngx_http_upstream_cleanup(r);
366 *u->cleanup = NULL;
367 }
368
369 u = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_t));
370 if (u == NULL) {
371 return NGX_ERROR;
372 }
373
374 r->upstream = u;
375
376 u->peer.log = r->connection->log;
377 u->peer.log_error = NGX_ERROR_ERR;
378 #if (NGX_THREADS)
379 u->peer.lock = &r->connection->lock;
380 #endif
381
382 return NGX_OK;
383 }
384
385
357 void 386 void
358 ngx_http_upstream_init(ngx_http_request_t *r) 387 ngx_http_upstream_init(ngx_http_request_t *r)
359 { 388 {
360 ngx_str_t *host; 389 ngx_str_t *host;
361 ngx_uint_t i; 390 ngx_uint_t i;
2862 u->pipe->temp_file->file.fd); 2891 u->pipe->temp_file->file.fd);
2863 } 2892 }
2864 2893
2865 #if (NGX_HTTP_CACHE) 2894 #if (NGX_HTTP_CACHE)
2866 2895
2867 if (u->cacheable) { 2896 if (u->cacheable && r->cache) {
2868 time_t valid; 2897 time_t valid;
2869 2898
2870 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 2899 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
2871 "http upstream cache fd: %d", 2900 "http upstream cache fd: %d",
2872 r->cache->file.fd); 2901 r->cache->file.fd);