comparison src/http/ngx_http_upstream.c @ 486:6484cbba0222 NGINX_0_7_55

nginx 0.7.55 *) Bugfix: the http_XXX parameters in "proxy_cache_use_stale" and "fastcgi_cache_use_stale" directives did not work. *) Bugfix: fastcgi cache did not cache header only responses. *) Bugfix: of "select() failed (9: Bad file descriptor)" error in nginx/Unix and "select() failed (10022: ...)" error in nginx/Windows. *) Bugfix: a segmentation fault might occur in worker process, if an "debug_connection" directive was used; the bug had appeared in 0.7.54. *) Bugfix: fix ngx_http_image_filter_module building errors. *) Bugfix: the files bigger than 2G could not be transferred using $r->sendfile. Thanks to Maxim Dounin.
author Igor Sysoev <http://sysoev.ru>
date Wed, 06 May 2009 00:00:00 +0400
parents ed5e10fb40fc
children 829f9a66a659
comparison
equal deleted inserted replaced
485:21824e8058e6 486:6484cbba0222
766 ngx_event_t *ev) 766 ngx_event_t *ev)
767 { 767 {
768 int n; 768 int n;
769 char buf[1]; 769 char buf[1];
770 ngx_err_t err; 770 ngx_err_t err;
771 ngx_int_t event;
771 ngx_connection_t *c; 772 ngx_connection_t *c;
772 ngx_http_upstream_t *u; 773 ngx_http_upstream_t *u;
773 774
774 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, ev->log, 0, 775 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, ev->log, 0,
775 "http upstream check client, write event:%d, \"%V\"", 776 "http upstream check client, write event:%d, \"%V\"",
777 778
778 c = r->connection; 779 c = r->connection;
779 u = r->upstream; 780 u = r->upstream;
780 781
781 if (c->error) { 782 if (c->error) {
783 if ((ngx_event_flags & NGX_USE_LEVEL_EVENT) && ev->active) {
784
785 event = ev->write ? NGX_WRITE_EVENT : NGX_READ_EVENT;
786
787 if (ngx_del_event(ev, event, 0) != NGX_OK) {
788 ngx_http_upstream_finalize_request(r, u,
789 NGX_HTTP_INTERNAL_SERVER_ERROR);
790 return;
791 }
792 }
793
782 if (!u->cacheable) { 794 if (!u->cacheable) {
783 ngx_http_upstream_finalize_request(r, u, 795 ngx_http_upstream_finalize_request(r, u,
784 NGX_HTTP_CLIENT_CLOSED_REQUEST); 796 NGX_HTTP_CLIENT_CLOSED_REQUEST);
785 } 797 }
798
786 return; 799 return;
787 } 800 }
788 801
789 if (u->peer.connection == NULL) { 802 if (u->peer.connection == NULL) {
790 return; 803 return;
834 err = ngx_socket_errno; 847 err = ngx_socket_errno;
835 848
836 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ev->log, err, 849 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ev->log, err,
837 "http upstream recv(): %d", n); 850 "http upstream recv(): %d", n);
838 851
839 /*
840 * we do not need to disable the write event because
841 * that event has NGX_USE_CLEAR_EVENT type
842 */
843
844 if (ev->write && (n >= 0 || err == NGX_EAGAIN)) { 852 if (ev->write && (n >= 0 || err == NGX_EAGAIN)) {
845 return; 853 return;
846 } 854 }
847 855
848 if ((ngx_event_flags & NGX_USE_LEVEL_EVENT) && ev->active) { 856 if ((ngx_event_flags & NGX_USE_LEVEL_EVENT) && ev->active) {
849 if (ngx_del_event(ev, NGX_READ_EVENT, 0) == NGX_ERROR) { 857
858 event = ev->write ? NGX_WRITE_EVENT : NGX_READ_EVENT;
859
860 if (ngx_del_event(ev, event, 0) != NGX_OK) {
850 ngx_http_upstream_finalize_request(r, u, 861 ngx_http_upstream_finalize_request(r, u,
851 NGX_HTTP_INTERNAL_SERVER_ERROR); 862 NGX_HTTP_INTERNAL_SERVER_ERROR);
852 return; 863 return;
853 } 864 }
854 } 865 }
1470 1481
1471 1482
1472 static ngx_int_t 1483 static ngx_int_t
1473 ngx_http_upstream_test_next(ngx_http_request_t *r, ngx_http_upstream_t *u) 1484 ngx_http_upstream_test_next(ngx_http_request_t *r, ngx_http_upstream_t *u)
1474 { 1485 {
1486 ngx_int_t rc;
1475 ngx_uint_t status; 1487 ngx_uint_t status;
1476 ngx_http_upstream_next_t *un; 1488 ngx_http_upstream_next_t *un;
1477
1478 if (!(u->conf->next_upstream & NGX_HTTP_UPSTREAM_FT_STATUS)) {
1479 return NGX_DECLINED;
1480 }
1481 1489
1482 status = u->headers_in.status_n; 1490 status = u->headers_in.status_n;
1483 1491
1484 for (un = ngx_http_upstream_next_errors; un->status; un++) { 1492 for (un = ngx_http_upstream_next_errors; un->status; un++) {
1485 1493
1492 return NGX_OK; 1500 return NGX_OK;
1493 } 1501 }
1494 1502
1495 #if (NGX_HTTP_CACHE) 1503 #if (NGX_HTTP_CACHE)
1496 1504
1497 if (u->peer.tries == 0 1505 if (u->stale_cache && (u->conf->cache_use_stale & un->mask)) {
1498 && u->stale_cache 1506
1499 && (u->conf->cache_use_stale & un->mask)) 1507 rc = u->reinit_request(r);
1500 { 1508
1501 ngx_http_upstream_finalize_request(r, u, 1509 if (rc == NGX_OK) {
1502 ngx_http_upstream_cache_send(r, u)); 1510 rc = ngx_http_upstream_cache_send(r, u);
1511 }
1512
1513 ngx_http_upstream_finalize_request(r, u, rc);
1503 return NGX_OK; 1514 return NGX_OK;
1504 } 1515 }
1505 1516
1506 #endif 1517 #endif
1507 } 1518 }
2648 if (u->peer.tries == 0 || !(u->conf->next_upstream & ft_type)) { 2659 if (u->peer.tries == 0 || !(u->conf->next_upstream & ft_type)) {
2649 2660
2650 #if (NGX_HTTP_CACHE) 2661 #if (NGX_HTTP_CACHE)
2651 2662
2652 if (u->stale_cache && (u->conf->cache_use_stale & ft_type)) { 2663 if (u->stale_cache && (u->conf->cache_use_stale & ft_type)) {
2653 2664 ngx_int_t rc;
2654 ngx_http_upstream_finalize_request(r, u, 2665
2655 ngx_http_upstream_cache_send(r, u)); 2666 rc = u->reinit_request(r);
2667
2668 if (rc == NGX_OK) {
2669 rc = ngx_http_upstream_cache_send(r, u);
2670 }
2671
2672 ngx_http_upstream_finalize_request(r, u, rc);
2656 return; 2673 return;
2657 } 2674 }
2658 #endif 2675 #endif
2659 2676
2660 ngx_http_upstream_finalize_request(r, u, status); 2677 ngx_http_upstream_finalize_request(r, u, status);