comparison src/http/ngx_http_upstream.c @ 4151:3549db8ceaf2

Cache: fix for sending of stale responses. For normal cached responses ngx_http_cache_send() sends last buffer and then request finalized via ngx_http_finalize_request() call, i.e. everything is ok. But for stale responses (i.e. when upstream died, but we have something in cache) the same ngx_http_cache_send() sends last buffer, but then in ngx_http_upstream_finalize_request() another last buffer is send. This causes duplicate final chunk to appear if chunked encoding is used (and resulting problems with keepalive connections and so on). Fix this by not sending in ngx_http_upstream_finalize_request() another last buffer if we know response was from cache.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 27 Sep 2011 11:17:11 +0000
parents 114e3a7c3b8d
children 65c1c241d70e
comparison
equal deleted inserted replaced
4150:b9ee14871bf1 4151:3549db8ceaf2
3070 return; 3070 return;
3071 } 3071 }
3072 3072
3073 r->connection->log->action = "sending to client"; 3073 r->connection->log->action = "sending to client";
3074 3074
3075 if (rc == 0) { 3075 if (rc == 0
3076 #if (NGX_HTTP_CACHE)
3077 && !r->cached
3078 #endif
3079 )
3080 {
3076 rc = ngx_http_send_special(r, NGX_HTTP_LAST); 3081 rc = ngx_http_send_special(r, NGX_HTTP_LAST);
3077 } 3082 }
3078 3083
3079 ngx_http_finalize_request(r, rc); 3084 ngx_http_finalize_request(r, rc);
3080 } 3085 }