Mercurial > hg > nginx
comparison src/http/modules/proxy/ngx_http_proxy_handler.c @ 189:c966c09be66b
nginx-0.0.1-2003-11-18-19:49:00 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 18 Nov 2003 16:49:00 +0000 |
parents | a8ff48d26cca |
children | 02a715e85df1 |
comparison
equal
deleted
inserted
replaced
188:0061d1f0908d | 189:c966c09be66b |
---|---|
336 | 336 |
337 return ngx_http_proxy_get_cached_response(p); | 337 return ngx_http_proxy_get_cached_response(p); |
338 } | 338 } |
339 | 339 |
340 | 340 |
341 void ngx_http_proxy_check_broken_connection(ngx_event_t *wev) | |
342 { | |
343 ngx_connection_t *c; | |
344 ngx_http_request_t *r; | |
345 ngx_http_proxy_ctx_t *p; | |
346 | |
347 ngx_log_debug(wev->log, "http proxy check client"); | |
348 | |
349 c = wev->data; | |
350 r = c->data; | |
351 p = ngx_http_get_module_ctx(r, ngx_http_proxy_module); | |
352 | |
353 #if (HAVE_KQUEUE) | |
354 if (wev->kq_eof) { | |
355 wev->eof = 1; | |
356 | |
357 if (wev->kq_errno) { | |
358 wev->error = 1; | |
359 } | |
360 | |
361 if (!p->cachable && p->upstream->peer.connection) { | |
362 ngx_log_error(NGX_LOG_INFO, wev->log, wev->kq_errno, | |
363 "client closed prematurely connection, " | |
364 "so upstream connection is closed too"); | |
365 ngx_http_proxy_finalize_request(p, NGX_HTTP_CLIENT_CLOSED_REQUEST); | |
366 return; | |
367 } | |
368 | |
369 ngx_log_error(NGX_LOG_INFO, wev->log, wev->kq_errno, | |
370 "client closed prematurely connection"); | |
371 | |
372 if (p->upstream == NULL || p->upstream->peer.connection == NULL) { | |
373 ngx_http_proxy_finalize_request(p, NGX_HTTP_CLIENT_CLOSED_REQUEST); | |
374 } | |
375 } | |
376 #endif | |
377 } | |
378 | |
379 | |
341 void ngx_http_proxy_busy_lock_handler(ngx_event_t *rev) | 380 void ngx_http_proxy_busy_lock_handler(ngx_event_t *rev) |
342 { | 381 { |
343 ngx_connection_t *c; | 382 ngx_connection_t *c; |
344 ngx_http_request_t *r; | 383 ngx_http_request_t *r; |
345 ngx_http_proxy_ctx_t *p; | 384 ngx_http_proxy_ctx_t *p; |
348 | 387 |
349 c = rev->data; | 388 c = rev->data; |
350 r = c->data; | 389 r = c->data; |
351 p = ngx_http_get_module_ctx(r, ngx_http_proxy_module); | 390 p = ngx_http_get_module_ctx(r, ngx_http_proxy_module); |
352 p->action = "waiting upstream in busy lock"; | 391 p->action = "waiting upstream in busy lock"; |
392 | |
393 if (p->request->connection->write->eof) { | |
394 ngx_http_busy_unlock(p->lcf->busy_lock, &p->busy_lock); | |
395 ngx_http_proxy_finalize_request(p, NGX_HTTP_CLIENT_CLOSED_REQUEST); | |
396 return; | |
397 } | |
353 | 398 |
354 if (rev->timedout) { | 399 if (rev->timedout) { |
355 rev->timedout = 0; | 400 rev->timedout = 0; |
356 p->busy_lock.time++; | 401 p->busy_lock.time++; |
357 p->state->bl_time = p->busy_lock.time; | 402 p->state->bl_time = p->busy_lock.time; |
367 | 412 |
368 ngx_log_debug(rev->log, "client sent while busy lock"); | 413 ngx_log_debug(rev->log, "client sent while busy lock"); |
369 | 414 |
370 /* | 415 /* |
371 * TODO: kevent() notify about error, otherwise we need to | 416 * TODO: kevent() notify about error, otherwise we need to |
372 * call ngx_peek(): recv(MGS_PEEK) to get errno. THINK about aio | 417 * call ngx_peek(): recv(MSG_PEEK) to get errno. THINK about aio |
373 * if there's no error we need to disable event. | 418 * if there's no error we need to disable event. |
374 */ | 419 */ |
375 | 420 |
421 #if 0 | |
376 #if (HAVE_KQUEUE) | 422 #if (HAVE_KQUEUE) |
377 | 423 |
378 if ((ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) && rev->kq_eof) { | 424 if ((ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) && rev->kq_eof) { |
379 p->lcf->busy_lock->waiting--; | 425 ngx_http_busy_unlock(p->lcf->busy_lock, &p->busy_lock); |
380 | 426 |
381 ngx_del_timer(rev); | 427 ngx_del_timer(rev); |
382 | 428 |
383 ngx_log_error(NGX_LOG_ERR, c->log, rev->kq_errno, | 429 ngx_log_error(NGX_LOG_ERR, c->log, rev->kq_errno, |
384 "client() closed connection"); | 430 "client() closed connection"); |
386 if (ngx_del_event(rev, NGX_READ_EVENT, NGX_CLOSE_EVENT) == NGX_ERROR) { | 432 if (ngx_del_event(rev, NGX_READ_EVENT, NGX_CLOSE_EVENT) == NGX_ERROR) { |
387 ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR); | 433 ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR); |
388 return; | 434 return; |
389 } | 435 } |
390 | 436 |
391 /* we have not HTTP code for the case when a client cancels a request */ | 437 ngx_http_proxy_finalize_request(p, NGX_HTTP_CLIENT_CLOSED_REQUEST); |
392 | |
393 ngx_http_proxy_finalize_request(p, 0); | |
394 return; | 438 return; |
395 } | 439 } |
396 | 440 |
441 #endif | |
397 #endif | 442 #endif |
398 | 443 |
399 } | 444 } |
400 | 445 |
401 | 446 |