comparison src/http/ngx_http_upstream.c @ 5746:35990c69b3ac

Upstream: p->downstream_error instead of closing connection. Previously, nginx closed client connection in cases when a response body from upstream was needed to be cached or stored but shouldn't be sent to the client. While this is normal for HTTP, it is unacceptable for SPDY. Fix is to use instead the p->downstream_error flag to prevent nginx from sending anything downstream. To make this work, the event pipe code was modified to properly cache empty responses with the flag set.
author Maxim Dounin <mdounin@mdounin.ru>
date Fri, 04 Jul 2014 20:47:16 +0400
parents 9d3a9c45fc43
children c5ec6944de98
comparison
equal deleted inserted replaced
5745:9d3a9c45fc43 5746:35990c69b3ac
2355 2355
2356 c = r->connection; 2356 c = r->connection;
2357 2357
2358 if (r->header_only) { 2358 if (r->header_only) {
2359 2359
2360 if (u->cacheable || u->store) { 2360 if (!u->buffering) {
2361
2362 if (ngx_shutdown_socket(c->fd, NGX_WRITE_SHUTDOWN) == -1) {
2363 ngx_connection_error(c, ngx_socket_errno,
2364 ngx_shutdown_socket_n " failed");
2365 }
2366
2367 r->read_event_handler = ngx_http_request_empty_handler;
2368 r->write_event_handler = ngx_http_request_empty_handler;
2369 c->error = 1;
2370
2371 } else {
2372 ngx_http_upstream_finalize_request(r, u, rc); 2361 ngx_http_upstream_finalize_request(r, u, rc);
2373 return; 2362 return;
2374 } 2363 }
2364
2365 if (!u->cacheable && !u->store) {
2366 ngx_http_upstream_finalize_request(r, u, rc);
2367 return;
2368 }
2369
2370 u->pipe->downstream_error = 1;
2375 } 2371 }
2376 2372
2377 if (r->request_body && r->request_body->temp_file) { 2373 if (r->request_body && r->request_body->temp_file) {
2378 ngx_pool_run_cleanup_file(r->pool, r->request_body->temp_file->file.fd); 2374 ngx_pool_run_cleanup_file(r->pool, r->request_body->temp_file->file.fd);
2379 r->request_body->temp_file->file.fd = NGX_INVALID_FILE; 2375 r->request_body->temp_file->file.fd = NGX_INVALID_FILE;