comparison src/http/ngx_http_upstream.c @ 340:10cc350ed8a1 NGINX_0_6_14

nginx 0.6.14 *) Change: now by default the "echo" SSI command uses entity encoding. *) Feature: the "encoding" parameter in the "echo" SSI command. *) Feature: the "access_log" directive may be used inside the "limit_except" block. *) Bugfix: if all upstream servers were failed, then all servers had got weight the was equal one until servers became alive; bug appeared in 0.6.6. *) Bugfix: a segmentation fault occurred in worker process if $date_local and $date_gmt were used outside the ngx_http_ssi_filter_module. *) Bugfix: a segmentation fault might occur in worker process if debug log was enabled. Thanks to Andrei Nigmatulin. *) Bugfix: ngx_http_memcached_module did not set $upstream_response_time. Thanks to Maxim Dounin. *) Bugfix: a worker process may got caught in an endless loop, if the memcached was used. *) Bugfix: nginx supported low case only "close" and "keep-alive" values in the "Connection" request header line; bug appeared in 0.6.11. *) Bugfix: sub_filter did not work with empty substitution. *) Bugfix: in sub_filter parsing.
author Igor Sysoev <http://sysoev.ru>
date Mon, 15 Oct 2007 00:00:00 +0400
parents 1c519aff5c0c
children 05693816539c
comparison
equal deleted inserted replaced
339:d19550b67059 340:10cc350ed8a1
432 432
433 if (ev->kq_errno) { 433 if (ev->kq_errno) {
434 ev->error = 1; 434 ev->error = 1;
435 } 435 }
436 436
437 if (!u->cachable && !u->store && u->peer.connection) { 437 if (!u->cacheable && !u->store && u->peer.connection) {
438 ngx_log_error(NGX_LOG_INFO, ev->log, ev->kq_errno, 438 ngx_log_error(NGX_LOG_INFO, ev->log, ev->kq_errno,
439 "kevent() reported that client closed prematurely " 439 "kevent() reported that client closed prematurely "
440 "connection, so upstream connection is closed too"); 440 "connection, so upstream connection is closed too");
441 ngx_http_upstream_finalize_request(r, u, 441 ngx_http_upstream_finalize_request(r, u,
442 NGX_HTTP_CLIENT_CLOSED_REQUEST); 442 NGX_HTTP_CLIENT_CLOSED_REQUEST);
498 } 498 }
499 499
500 ev->eof = 1; 500 ev->eof = 1;
501 c->error = 1; 501 c->error = 1;
502 502
503 if (!u->cachable && !u->store && u->peer.connection) { 503 if (!u->cacheable && !u->store && u->peer.connection) {
504 ngx_log_error(NGX_LOG_INFO, ev->log, err, 504 ngx_log_error(NGX_LOG_INFO, ev->log, err,
505 "client closed prematurely connection, " 505 "client closed prematurely connection, "
506 "so upstream connection is closed too"); 506 "so upstream connection is closed too");
507 ngx_http_upstream_finalize_request(r, u, 507 ngx_http_upstream_finalize_request(r, u,
508 NGX_HTTP_CLIENT_CLOSED_REQUEST); 508 NGX_HTTP_CLIENT_CLOSED_REQUEST);
978 u->buffer.last = u->buffer.pos; 978 u->buffer.last = u->buffer.pos;
979 } 979 }
980 #endif 980 #endif
981 } 981 }
982 982
983 n = u->peer.connection->recv(u->peer.connection, u->buffer.last, 983 n = c->recv(c, u->buffer.last, u->buffer.end - u->buffer.last);
984 u->buffer.end - u->buffer.last);
985 984
986 if (n == NGX_AGAIN) { 985 if (n == NGX_AGAIN) {
987 #if 0 986 #if 0
988 ngx_add_timer(rev, u->read_timeout); 987 ngx_add_timer(rev, u->read_timeout);
989 #endif 988 #endif
1512 ngx_close_file_n " \"%s\" failed", 1511 ngx_close_file_n " \"%s\" failed",
1513 u->cache->ctx.file.name.data); 1512 u->cache->ctx.file.name.data);
1514 } 1513 }
1515 } 1514 }
1516 1515
1517 if (u->cachable) { 1516 if (u->cacheable) {
1518 header = (ngx_http_cache_header_t *) u->buffer->start; 1517 header = (ngx_http_cache_header_t *) u->buffer->start;
1519 1518
1520 header->expires = u->cache->ctx.expires; 1519 header->expires = u->cache->ctx.expires;
1521 header->last_modified = u->cache->ctx.last_modified; 1520 header->last_modified = u->cache->ctx.last_modified;
1522 header->date = u->cache->ctx.date; 1521 header->date = u->cache->ctx.date;
1540 p->upstream = u->peer.connection; 1539 p->upstream = u->peer.connection;
1541 p->downstream = c; 1540 p->downstream = c;
1542 p->pool = r->pool; 1541 p->pool = r->pool;
1543 p->log = c->log; 1542 p->log = c->log;
1544 1543
1545 p->cachable = u->cachable || u->store; 1544 p->cacheable = u->cacheable || u->store;
1546 1545
1547 p->temp_file = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t)); 1546 p->temp_file = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t));
1548 if (p->temp_file == NULL) { 1547 if (p->temp_file == NULL) {
1549 ngx_http_upstream_finalize_request(r, u, 0); 1548 ngx_http_upstream_finalize_request(r, u, 0);
1550 return; 1549 return;
1553 p->temp_file->file.fd = NGX_INVALID_FILE; 1552 p->temp_file->file.fd = NGX_INVALID_FILE;
1554 p->temp_file->file.log = c->log; 1553 p->temp_file->file.log = c->log;
1555 p->temp_file->path = u->conf->temp_path; 1554 p->temp_file->path = u->conf->temp_path;
1556 p->temp_file->pool = r->pool; 1555 p->temp_file->pool = r->pool;
1557 1556
1558 if (u->cachable || u->store) { 1557 if (u->cacheable || u->store) {
1559 p->temp_file->persistent = 1; 1558 p->temp_file->persistent = 1;
1560 1559
1561 } else { 1560 } else {
1562 p->temp_file->log_level = NGX_LOG_WARN; 1561 p->temp_file->log_level = NGX_LOG_WARN;
1563 p->temp_file->warn = "an upstream response is buffered " 1562 p->temp_file->warn = "an upstream response is buffered "
1577 p->preread_bufs->next = NULL; 1576 p->preread_bufs->next = NULL;
1578 u->buffer.recycled = 1; 1577 u->buffer.recycled = 1;
1579 1578
1580 p->preread_size = u->buffer.last - u->buffer.pos; 1579 p->preread_size = u->buffer.last - u->buffer.pos;
1581 1580
1582 if (u->cachable) { 1581 if (u->cacheable) {
1583 1582
1584 p->buf_to_file = ngx_calloc_buf(r->pool); 1583 p->buf_to_file = ngx_calloc_buf(r->pool);
1585 if (p->buf_to_file == NULL) { 1584 if (p->buf_to_file == NULL) {
1586 ngx_http_upstream_finalize_request(r, u, 0); 1585 ngx_http_upstream_finalize_request(r, u, 0);
1587 return; 1586 return;
1954 } 1953 }
1955 } 1954 }
1956 1955
1957 #if (NGX_HTTP_FILE_CACHE) 1956 #if (NGX_HTTP_FILE_CACHE)
1958 1957
1959 if (p->upstream_done && u->cachable) { 1958 if (p->upstream_done && u->cacheable) {
1960 if (ngx_http_cache_update(r) == NGX_ERROR) { 1959 if (ngx_http_cache_update(r) == NGX_ERROR) {
1961 ngx_http_busy_unlock(u->conf->busy_lock, &u->busy_lock); 1960 ngx_http_busy_unlock(u->conf->busy_lock, &u->busy_lock);
1962 ngx_http_upstream_finalize_request(r, u, 0); 1961 ngx_http_upstream_finalize_request(r, u, 0);
1963 return; 1962 return;
1964 } 1963 }
1965 1964
1966 } else if (p->upstream_eof && u->cachable) { 1965 } else if (p->upstream_eof && u->cacheable) {
1967 1966
1968 /* TODO: check length & update cache */ 1967 /* TODO: check length & update cache */
1969 1968
1970 if (ngx_http_cache_update(r) == NGX_ERROR) { 1969 if (ngx_http_cache_update(r) == NGX_ERROR) {
1971 ngx_http_busy_unlock(u->conf->busy_lock, &u->busy_lock); 1970 ngx_http_busy_unlock(u->conf->busy_lock, &u->busy_lock);
1989 1988
1990 if (p->downstream_error) { 1989 if (p->downstream_error) {
1991 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, 1990 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
1992 "http upstream downstream error"); 1991 "http upstream downstream error");
1993 1992
1994 if (!u->cachable && u->peer.connection) { 1993 if (!u->cacheable && u->peer.connection) {
1995 ngx_http_upstream_finalize_request(r, u, 0); 1994 ngx_http_upstream_finalize_request(r, u, 0);
1996 } 1995 }
1997 } 1996 }
1998 } 1997 }
1999 1998
2634 2633
2635 *ho = *h; 2634 *ho = *h;
2636 2635
2637 if (r->upstream->rewrite_redirect) { 2636 if (r->upstream->rewrite_redirect) {
2638 2637
2639 p = (u_char *) ngx_strstr(ho->value.data, "url="); 2638 p = ngx_strcasestrn(ho->value.data, "url=", 4 - 1);
2640 2639
2641 if (p) { 2640 if (p) {
2642 rc = r->upstream->rewrite_redirect(r, ho, p + 4 - ho->value.data); 2641 rc = r->upstream->rewrite_redirect(r, ho, p + 4 - ho->value.data);
2643 2642
2644 } else { 2643 } else {
2713 size_t len; 2712 size_t len;
2714 ngx_uint_t i; 2713 ngx_uint_t i;
2715 ngx_http_upstream_state_t *state; 2714 ngx_http_upstream_state_t *state;
2716 2715
2717 v->valid = 1; 2716 v->valid = 1;
2718 v->no_cachable = 0; 2717 v->no_cacheable = 0;
2719 v->not_found = 0; 2718 v->not_found = 0;
2720 2719
2721 if (r->upstream_states == NULL || r->upstream_states->nelts == 0) { 2720 if (r->upstream_states == NULL || r->upstream_states->nelts == 0) {
2722 v->not_found = 1; 2721 v->not_found = 1;
2723 return NGX_OK; 2722 return NGX_OK;
2784 size_t len; 2783 size_t len;
2785 ngx_uint_t i; 2784 ngx_uint_t i;
2786 ngx_http_upstream_state_t *state; 2785 ngx_http_upstream_state_t *state;
2787 2786
2788 v->valid = 1; 2787 v->valid = 1;
2789 v->no_cachable = 0; 2788 v->no_cacheable = 0;
2790 v->not_found = 0; 2789 v->not_found = 0;
2791 2790
2792 if (r->upstream_states == NULL || r->upstream_states->nelts == 0) { 2791 if (r->upstream_states == NULL || r->upstream_states->nelts == 0) {
2793 v->not_found = 1; 2792 v->not_found = 1;
2794 return NGX_OK; 2793 return NGX_OK;
2850 ngx_uint_t i; 2849 ngx_uint_t i;
2851 ngx_msec_int_t ms; 2850 ngx_msec_int_t ms;
2852 ngx_http_upstream_state_t *state; 2851 ngx_http_upstream_state_t *state;
2853 2852
2854 v->valid = 1; 2853 v->valid = 1;
2855 v->no_cachable = 0; 2854 v->no_cacheable = 0;
2856 v->not_found = 0; 2855 v->not_found = 0;
2857 2856
2858 if (r->upstream_states == NULL || r->upstream_states->nelts == 0) { 2857 if (r->upstream_states == NULL || r->upstream_states->nelts == 0) {
2859 v->not_found = 1; 2858 v->not_found = 1;
2860 return NGX_OK; 2859 return NGX_OK;
3064 ngx_memzero(&u, sizeof(ngx_url_t)); 3063 ngx_memzero(&u, sizeof(ngx_url_t));
3065 3064
3066 u.url = value[1]; 3065 u.url = value[1];
3067 u.default_port = 80; 3066 u.default_port = 80;
3068 3067
3069 if (ngx_parse_url(cf, &u) != NGX_OK) { 3068 if (ngx_parse_url(cf->pool, &u) != NGX_OK) {
3070 if (u.err) { 3069 if (u.err) {
3071 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 3070 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
3072 "%s in upstream \"%V\"", u.err, &u.url); 3071 "%s in upstream \"%V\"", u.err, &u.url);
3073 } 3072 }
3074 3073
3179 ngx_http_upstream_srv_conf_t *uscf, **uscfp; 3178 ngx_http_upstream_srv_conf_t *uscf, **uscfp;
3180 ngx_http_upstream_main_conf_t *umcf; 3179 ngx_http_upstream_main_conf_t *umcf;
3181 3180
3182 if (!(flags & NGX_HTTP_UPSTREAM_CREATE)) { 3181 if (!(flags & NGX_HTTP_UPSTREAM_CREATE)) {
3183 3182
3184 if (ngx_parse_url(cf, u) != NGX_OK) { 3183 if (ngx_parse_url(cf->pool, u) != NGX_OK) {
3185 if (u->err) { 3184 if (u->err) {
3186 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 3185 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
3187 "%s in upstream \"%V\"", u->err, &u->url); 3186 "%s in upstream \"%V\"", u->err, &u->url);
3188 } 3187 }
3189 3188