comparison src/http/ngx_http_request.c @ 2902:a1a1c7e3fb8d

fix "out of memory" case handling
author Igor Sysoev <igor@sysoev.ru>
date Fri, 29 May 2009 11:42:55 +0000
parents 512d164a8348
children 5acd98486a33
comparison
equal deleted inserted replaced
2901:17da2da3a8f5 2902:a1a1c7e3fb8d
449 449
450 if (ngx_list_init(&r->headers_out.headers, r->pool, 20, 450 if (ngx_list_init(&r->headers_out.headers, r->pool, 20,
451 sizeof(ngx_table_elt_t)) 451 sizeof(ngx_table_elt_t))
452 != NGX_OK) 452 != NGX_OK)
453 { 453 {
454 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); 454 ngx_destroy_pool(r->pool);
455 ngx_http_close_connection(c);
455 return; 456 return;
456 } 457 }
457 458
458 r->ctx = ngx_pcalloc(r->pool, sizeof(void *) * ngx_http_max_module); 459 r->ctx = ngx_pcalloc(r->pool, sizeof(void *) * ngx_http_max_module);
459 if (r->ctx == NULL) { 460 if (r->ctx == NULL) {
460 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); 461 ngx_destroy_pool(r->pool);
462 ngx_http_close_connection(c);
461 return; 463 return;
462 } 464 }
463 465
464 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); 466 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
465 467
466 r->variables = ngx_pcalloc(r->pool, cmcf->variables.nelts 468 r->variables = ngx_pcalloc(r->pool, cmcf->variables.nelts
467 * sizeof(ngx_http_variable_value_t)); 469 * sizeof(ngx_http_variable_value_t));
468 if (r->variables == NULL) { 470 if (r->variables == NULL) {
469 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); 471 ngx_destroy_pool(r->pool);
472 ngx_http_close_connection(c);
470 return; 473 return;
471 } 474 }
472 475
473 c->single_connection = 1; 476 c->single_connection = 1;
474 c->destroyed = 0; 477 c->destroyed = 0;