comparison src/http/ngx_http_upstream.c @ 1714:6b81bbc36eaf stable-0.5

r1566 merge: fix English grammar
author Igor Sysoev <igor@sysoev.ru>
date Wed, 12 Dec 2007 16:57:36 +0000
parents 20a0f2880d45
children c7757ce0ae97
comparison
equal deleted inserted replaced
1713:389aeafc3b84 1714:6b81bbc36eaf
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);
1509 ngx_close_file_n " \"%s\" failed", 1509 ngx_close_file_n " \"%s\" failed",
1510 u->cache->ctx.file.name.data); 1510 u->cache->ctx.file.name.data);
1511 } 1511 }
1512 } 1512 }
1513 1513
1514 if (u->cachable) { 1514 if (u->cacheable) {
1515 header = (ngx_http_cache_header_t *) u->buffer->start; 1515 header = (ngx_http_cache_header_t *) u->buffer->start;
1516 1516
1517 header->expires = u->cache->ctx.expires; 1517 header->expires = u->cache->ctx.expires;
1518 header->last_modified = u->cache->ctx.last_modified; 1518 header->last_modified = u->cache->ctx.last_modified;
1519 header->date = u->cache->ctx.date; 1519 header->date = u->cache->ctx.date;
1537 p->upstream = u->peer.connection; 1537 p->upstream = u->peer.connection;
1538 p->downstream = c; 1538 p->downstream = c;
1539 p->pool = r->pool; 1539 p->pool = r->pool;
1540 p->log = c->log; 1540 p->log = c->log;
1541 1541
1542 p->cachable = u->cachable || u->store; 1542 p->cacheable = u->cacheable || u->store;
1543 1543
1544 p->temp_file = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t)); 1544 p->temp_file = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t));
1545 if (p->temp_file == NULL) { 1545 if (p->temp_file == NULL) {
1546 ngx_http_upstream_finalize_request(r, u, 0); 1546 ngx_http_upstream_finalize_request(r, u, 0);
1547 return; 1547 return;
1550 p->temp_file->file.fd = NGX_INVALID_FILE; 1550 p->temp_file->file.fd = NGX_INVALID_FILE;
1551 p->temp_file->file.log = c->log; 1551 p->temp_file->file.log = c->log;
1552 p->temp_file->path = u->conf->temp_path; 1552 p->temp_file->path = u->conf->temp_path;
1553 p->temp_file->pool = r->pool; 1553 p->temp_file->pool = r->pool;
1554 1554
1555 if (u->cachable || u->store) { 1555 if (u->cacheable || u->store) {
1556 p->temp_file->persistent = 1; 1556 p->temp_file->persistent = 1;
1557 1557
1558 } else { 1558 } else {
1559 p->temp_file->log_level = NGX_LOG_WARN; 1559 p->temp_file->log_level = NGX_LOG_WARN;
1560 p->temp_file->warn = "an upstream response is buffered " 1560 p->temp_file->warn = "an upstream response is buffered "
1574 p->preread_bufs->next = NULL; 1574 p->preread_bufs->next = NULL;
1575 u->buffer.recycled = 1; 1575 u->buffer.recycled = 1;
1576 1576
1577 p->preread_size = u->buffer.last - u->buffer.pos; 1577 p->preread_size = u->buffer.last - u->buffer.pos;
1578 1578
1579 if (u->cachable) { 1579 if (u->cacheable) {
1580 1580
1581 p->buf_to_file = ngx_calloc_buf(r->pool); 1581 p->buf_to_file = ngx_calloc_buf(r->pool);
1582 if (p->buf_to_file == NULL) { 1582 if (p->buf_to_file == NULL) {
1583 ngx_http_upstream_finalize_request(r, u, 0); 1583 ngx_http_upstream_finalize_request(r, u, 0);
1584 return; 1584 return;
1951 } 1951 }
1952 } 1952 }
1953 1953
1954 #if (NGX_HTTP_FILE_CACHE) 1954 #if (NGX_HTTP_FILE_CACHE)
1955 1955
1956 if (p->upstream_done && u->cachable) { 1956 if (p->upstream_done && u->cacheable) {
1957 if (ngx_http_cache_update(r) == NGX_ERROR) { 1957 if (ngx_http_cache_update(r) == NGX_ERROR) {
1958 ngx_http_busy_unlock(u->conf->busy_lock, &u->busy_lock); 1958 ngx_http_busy_unlock(u->conf->busy_lock, &u->busy_lock);
1959 ngx_http_upstream_finalize_request(r, u, 0); 1959 ngx_http_upstream_finalize_request(r, u, 0);
1960 return; 1960 return;
1961 } 1961 }
1962 1962
1963 } else if (p->upstream_eof && u->cachable) { 1963 } else if (p->upstream_eof && u->cacheable) {
1964 1964
1965 /* TODO: check length & update cache */ 1965 /* TODO: check length & update cache */
1966 1966
1967 if (ngx_http_cache_update(r) == NGX_ERROR) { 1967 if (ngx_http_cache_update(r) == NGX_ERROR) {
1968 ngx_http_busy_unlock(u->conf->busy_lock, &u->busy_lock); 1968 ngx_http_busy_unlock(u->conf->busy_lock, &u->busy_lock);
1986 1986
1987 if (p->downstream_error) { 1987 if (p->downstream_error) {
1988 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, 1988 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
1989 "http upstream downstream error"); 1989 "http upstream downstream error");
1990 1990
1991 if (!u->cachable && u->peer.connection) { 1991 if (!u->cacheable && u->peer.connection) {
1992 ngx_http_upstream_finalize_request(r, u, 0); 1992 ngx_http_upstream_finalize_request(r, u, 0);
1993 } 1993 }
1994 } 1994 }
1995 } 1995 }
1996 1996
2708 size_t len; 2708 size_t len;
2709 ngx_uint_t i; 2709 ngx_uint_t i;
2710 ngx_http_upstream_state_t *state; 2710 ngx_http_upstream_state_t *state;
2711 2711
2712 v->valid = 1; 2712 v->valid = 1;
2713 v->no_cachable = 0; 2713 v->no_cacheable = 0;
2714 v->not_found = 0; 2714 v->not_found = 0;
2715 2715
2716 if (r->upstream_states == NULL || r->upstream_states->nelts == 0) { 2716 if (r->upstream_states == NULL || r->upstream_states->nelts == 0) {
2717 v->not_found = 1; 2717 v->not_found = 1;
2718 return NGX_OK; 2718 return NGX_OK;
2779 size_t len; 2779 size_t len;
2780 ngx_uint_t i; 2780 ngx_uint_t i;
2781 ngx_http_upstream_state_t *state; 2781 ngx_http_upstream_state_t *state;
2782 2782
2783 v->valid = 1; 2783 v->valid = 1;
2784 v->no_cachable = 0; 2784 v->no_cacheable = 0;
2785 v->not_found = 0; 2785 v->not_found = 0;
2786 2786
2787 if (r->upstream_states == NULL || r->upstream_states->nelts == 0) { 2787 if (r->upstream_states == NULL || r->upstream_states->nelts == 0) {
2788 v->not_found = 1; 2788 v->not_found = 1;
2789 return NGX_OK; 2789 return NGX_OK;
2845 ngx_uint_t i; 2845 ngx_uint_t i;
2846 ngx_msec_int_t ms; 2846 ngx_msec_int_t ms;
2847 ngx_http_upstream_state_t *state; 2847 ngx_http_upstream_state_t *state;
2848 2848
2849 v->valid = 1; 2849 v->valid = 1;
2850 v->no_cachable = 0; 2850 v->no_cacheable = 0;
2851 v->not_found = 0; 2851 v->not_found = 0;
2852 2852
2853 if (r->upstream_states == NULL || r->upstream_states->nelts == 0) { 2853 if (r->upstream_states == NULL || r->upstream_states->nelts == 0) {
2854 v->not_found = 1; 2854 v->not_found = 1;
2855 return NGX_OK; 2855 return NGX_OK;