nginx-0.0.1-2003-11-25-23:44:56 import
diff --git a/src/http/modules/ngx_http_chunked_filter.c b/src/http/modules/ngx_http_chunked_filter.c index 5e7bd28..ed7b460 100644 --- a/src/http/modules/ngx_http_chunked_filter.c +++ b/src/http/modules/ngx_http_chunked_filter.c
@@ -87,7 +87,7 @@ } ngx_test_null(chunk, ngx_palloc(r->pool, 11), NGX_ERROR); - len = ngx_snprintf(chunk, 11, SIZEX_FMT CRLF, size); + len = ngx_snprintf(chunk, 11, SIZE_T_X_FMT CRLF, size); ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR); h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_TEMP;
diff --git a/src/http/modules/ngx_http_not_modified_filter.c b/src/http/modules/ngx_http_not_modified_filter.c index c623752..11cc21c 100644 --- a/src/http/modules/ngx_http_not_modified_filter.c +++ b/src/http/modules/ngx_http_not_modified_filter.c
@@ -58,11 +58,13 @@ if (ims != NGX_ERROR && ims == r->headers_out.last_modified_time) { r->headers_out.status = NGX_HTTP_NOT_MODIFIED; - r->headers_out.content_length_n = -1; - r->headers_out.content_length = NULL; r->headers_out.content_type->key.len = 0; r->headers_out.content_type = NULL; + r->headers_out.content_length_n = -1; + r->headers_out.content_length = NULL; +#if 0 r->headers_out.accept_ranges->key.len = 0; +#endif } return ngx_http_next_header_filter(r);
diff --git a/src/http/modules/ngx_http_range_filter.c b/src/http/modules/ngx_http_range_filter.c index 11b7d0f..bf28fe1 100644 --- a/src/http/modules/ngx_http_range_filter.c +++ b/src/http/modules/ngx_http_range_filter.c
@@ -215,7 +215,7 @@ r->headers_out.content_range->value.len = ngx_snprintf(r->headers_out.content_range->value.data, - 8 + 20 + 1, "bytes */" OFF_FMT, + 8 + 20 + 1, "bytes */" OFF_T_FMT, r->headers_out.content_length_n); r->headers_out.content_length_n = -1; @@ -247,11 +247,11 @@ /* "Content-Range: bytes SSSS-EEEE/TTTT" header */ r->headers_out.content_range->value.len = - ngx_snprintf(r->headers_out.content_range->value.data, - 6 + 20 + 1 + 20 + 1 + 20 + 1, - "bytes " OFF_FMT "-" OFF_FMT "/" OFF_FMT, - range->start, range->end - 1, - r->headers_out.content_length_n); + ngx_snprintf(r->headers_out.content_range->value.data, + 6 + 20 + 1 + 20 + 1 + 20 + 1, + "bytes " OFF_T_FMT "-" OFF_T_FMT "/" OFF_T_FMT, + range->start, range->end - 1, + r->headers_out.content_length_n); r->headers_out.content_length_n = range->end - range->start; @@ -336,11 +336,11 @@ /* the size of the range: "SSSS-EEEE/TTTT" CRLF CRLF */ range[i].content_range.len = - ngx_snprintf(range[i].content_range.data, - 20 + 1 + 20 + 1 + 20 + 5, - OFF_FMT "-" OFF_FMT "/" OFF_FMT CRLF CRLF, - range[i].start, range[i].end - 1, - r->headers_out.content_length_n); + ngx_snprintf(range[i].content_range.data, + 20 + 1 + 20 + 1 + 20 + 5, + OFF_T_FMT "-" OFF_T_FMT "/" OFF_T_FMT CRLF CRLF, + range[i].start, range[i].end - 1, + r->headers_out.content_length_n); len += ctx->boundary_header.len + range[i].content_range.len + (size_t) (range[i].end - range[i].start);
diff --git a/src/http/modules/ngx_http_static_handler.c b/src/http/modules/ngx_http_static_handler.c index 69f1a14..80af266 100644 --- a/src/http/modules/ngx_http_static_handler.c +++ b/src/http/modules/ngx_http_static_handler.c
@@ -44,6 +44,8 @@ int rc, level; char *location, *last; ngx_err_t err; + ngx_http_cache_ctx_t ctx; + ngx_http_cache_conf_t *ccf; ngx_http_core_loc_conf_t *clcf; if (r->method != NGX_HTTP_GET && r->method != NGX_HTTP_HEAD) { @@ -73,7 +75,7 @@ return NGX_HTTP_FORBIDDEN; } - /* "+ 2" is for trailing '/' in redirect and '\0' */ + /* "+ 2" is for trailing '/' in possible redirect and '\0' */ ngx_test_null(r->file.name.data, ngx_palloc(r->pool, clcf->doc_root.len + r->uri.len + 2), NGX_HTTP_INTERNAL_SERVER_ERROR); @@ -85,6 +87,38 @@ ngx_log_debug(r->connection->log, "HTTP filename: '%s'" _ r->file.name.data); + + /* STUB */ + ccf = NULL; + ctx.key.len = 0; + +#if 0 + ccf = ngx_http_get_module_loc_conf(r, ngx_http_cache_module); + + if (ccf->open_files) { + ctx->hash = ccf->open_files; + ctx->key = r->file.name; + + cache = ngx_http_cache_get_data(r, ctx); + + if (cache + && ((ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) + || ccf->hash->life_time >= ngx_time() - cache->updated)) + { + cache->refs++; + r->file.fd = cache->fd; + r->file.name = cache->key; + r->content_handler = ngx_http_static_handler; + + return NGX_OK; + } + + } else { + cache = NULL; + } + +#endif + #if (WIN9X) if (ngx_win32_version < NGX_WIN_NT) {
diff --git a/src/http/modules/proxy/ngx_http_proxy_cache.c b/src/http/modules/proxy/ngx_http_proxy_cache.c index 05fec3a..9661cff 100644 --- a/src/http/modules/proxy/ngx_http_proxy_cache.c +++ b/src/http/modules/proxy/ngx_http_proxy_cache.c
@@ -86,6 +86,7 @@ } if (rc == NGX_HTTP_CACHE_STALE || rc == NGX_HTTP_CACHE_AGED) { + p->state->expired = ngx_time() - p->cache->ctx.expires; p->header_in->pos = p->header_in->start + p->cache->ctx.header_size; if (ngx_http_proxy_process_cached_header(p) == NGX_ERROR) { @@ -487,6 +488,8 @@ out[i].hunk->type |= NGX_HUNK_LAST; } + r->file.fd = p->cache->ctx.file.fd; + return ngx_http_output_filter(r, out); } @@ -600,7 +603,7 @@ ep = p->upstream->event_pipe; -ngx_log_debug(p->request->connection->log, "LEN: " OFF_FMT ", " OFF_FMT _ +ngx_log_debug(p->request->connection->log, "LEN: " OFF_T_FMT ", " OFF_T_FMT _ p->cache->ctx.length _ ep->read_length); if (p->cache->ctx.length == -1) {
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c index 25f5b33..e8b78f4 100644 --- a/src/http/modules/proxy/ngx_http_proxy_handler.c +++ b/src/http/modules/proxy/ngx_http_proxy_handler.c
@@ -485,6 +485,10 @@ r->file.fd = p->cache->ctx.file.fd; } + if (rc == 0 && r->main == NULL) { + rc = ngx_http_send_last(r); + } + ngx_http_finalize_request(r, rc); } @@ -586,15 +590,25 @@ *buf++ = '/'; - *buf++ = '_'; + if (p->state->expired == 0) { + *buf++ = '-'; + + } else { + buf += ngx_snprintf(buf, NGX_TIME_LEN, TIME_T_FMT, p->state->expired); + } *buf++ = '/'; - *buf++ = '_'; + if (p->state->bl_time == 0) { + *buf++ = '-'; + + } else { + buf += ngx_snprintf(buf, NGX_TIME_LEN, TIME_T_FMT, p->state->bl_time); + } *buf++ = '/'; - *buf++ = '_'; + *buf++ = '*'; *buf++ = ' '; @@ -617,15 +631,15 @@ *buf++ = '/'; - if (p->state->reason >= NGX_HTTP_PROXY_CACHE_XAE) { + if (p->state->reason < NGX_HTTP_PROXY_CACHE_XAE) { *buf++ = '-'; } else { - buf += ngx_snprintf(buf, NGX_TIME_LEN, TIME_FMT, p->state->expires); + buf += ngx_snprintf(buf, NGX_TIME_LEN, TIME_T_FMT, p->state->expires); } *buf++ = ' '; - *buf++ = '_'; + *buf++ = '*'; return buf; } @@ -833,9 +847,9 @@ int i, len; char *err, *host; + in_addr_t addr; ngx_str_t *value; struct hostent *h; - u_int32_t addr; ngx_http_conf_ctx_t *ctx; ngx_http_core_loc_conf_t *clcf; @@ -869,6 +883,8 @@ NGX_CONF_ERROR); ngx_cpystrn(host, lcf->upstream->host.data, lcf->upstream->host.len + 1); + /* AF_INET only */ + addr = inet_addr(host); if (addr == INADDR_NONE) { @@ -894,7 +910,7 @@ for (i = 0; h->h_addr_list[i] != NULL; i++) { lcf->peers->peers[i].host.data = host; lcf->peers->peers[i].host.len = lcf->upstream->host.len; - lcf->peers->peers[i].addr = *(u_int32_t *)(h->h_addr_list[i]); + lcf->peers->peers[i].addr = *(in_addr_t *)(h->h_addr_list[i]); lcf->peers->peers[i].port = lcf->upstream->port; len = INET_ADDRSTRLEN + lcf->upstream->port_text.len + 1;
diff --git a/src/http/modules/proxy/ngx_http_proxy_upstream.c b/src/http/modules/proxy/ngx_http_proxy_upstream.c index 1b1ca44..d36cbee 100644 --- a/src/http/modules/proxy/ngx_http_proxy_upstream.c +++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c
@@ -1017,8 +1017,7 @@ ep->hunk_to_file->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_TEMP; if (ngx_event_flags & NGX_USE_AIO_EVENT) { - - /* the posted aio operation can currupt shadow buf */ + /* the posted aio operation can currupt a shadow buffer */ ep->single_buf = 1; } @@ -1126,26 +1125,38 @@ } if (ep->upstream_done || ep->upstream_eof || ep->upstream_error) { + ngx_log_debug(ev->log, "http proxy upstream exit"); ngx_http_busy_unlock(p->lcf->busy_lock, &p->busy_lock); - ngx_http_proxy_close_connection(p); + ngx_http_proxy_finalize_request(p, 0); + return; } } + if (ep->downstream_error) { + ngx_log_debug(ev->log, "http proxy downstream error"); + if (!p->cachable && p->upstream->peer.connection) { + ngx_http_proxy_finalize_request(p, 0); + } + } + +#if 0 if (ep->downstream_done) { ngx_log_debug(ev->log, "http proxy downstream done"); - ngx_http_proxy_finalize_request(p, r->main ? 0 : ngx_http_send_last(r)); + ngx_http_proxy_finalize_request(p, 0); return; } if (ep->downstream_error) { + ngx_log_debug(ev->log, "http proxy downstream error"); if (!p->cachable && p->upstream->peer.connection) { ngx_http_proxy_close_connection(p); } if (p->upstream->peer.connection == NULL) { - ngx_http_close_connection(r->connection); + ngx_http_close_request(r); } } +#endif }