comparison ngx_http_upstream_keepalive_module.c @ 26:cb15f6f4d820

Keepalive: don't cache timed out connections.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 26 Jul 2011 12:51:14 +0400
parents 2ee28064a04a
children baf671881a8d
comparison
equal deleted inserted replaced
25:c6396fef9295 26:cb15f6f4d820
307 * 307 *
308 * TODO: move this logic to protocol modules (NGX_PEER_KEEPALIVE?) 308 * TODO: move this logic to protocol modules (NGX_PEER_KEEPALIVE?)
309 */ 309 */
310 310
311 u = kp->upstream; 311 u = kp->upstream;
312 c = pc->connection;
312 status = u->headers_in.status_n; 313 status = u->headers_in.status_n;
313 314
314 if (!kp->failed 315 if (!kp->failed
315 && pc->connection != NULL 316 && c != NULL
317 && !c->read->timedout
318 && !c->write->timedout
316 #if (NGX_UPSTREAM_KEEPALIVE_PATCHED) 319 #if (NGX_UPSTREAM_KEEPALIVE_PATCHED)
317 && u->keepalive) 320 && u->keepalive)
318 #else 321 #else
319 && (status == NGX_HTTP_NOT_FOUND 322 && (status == NGX_HTTP_NOT_FOUND
320 || (status == NGX_HTTP_OK && u->header_sent && u->length == 0))) 323 || (status == NGX_HTTP_OK && u->header_sent && u->length == 0)))
321 #endif 324 #endif
322 { 325 {
323 c = pc->connection;
324
325 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0, 326 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
326 "free keepalive peer: saving connection %p", c); 327 "free keepalive peer: saving connection %p", c);
327 328
328 if (ngx_queue_empty(&kp->conf->free)) { 329 if (ngx_queue_empty(&kp->conf->free)) {
329 330