diff options
Diffstat (limited to '')
| -rw-r--r-- | src/http/ngx_http.c | 7 | ||||
| -rw-r--r-- | src/http/ngx_http_event.c | 106 | ||||
| -rw-r--r-- | src/http/ngx_http_get_time.c | 2 | ||||
| -rw-r--r-- | src/http/ngx_http_header_filter.c | 8 | ||||
| -rw-r--r-- | src/http/ngx_http_output_filter.c | 28 | ||||
| -rw-r--r-- | src/http/ngx_http_parse.c | 13 | ||||
| -rw-r--r-- | src/http/ngx_http_parse_time.c | 5 |
7 files changed, 74 insertions, 95 deletions
diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c index 56e2b5b72..5396fa2f5 100644 --- a/src/http/ngx_http.c +++ b/src/http/ngx_http.c @@ -1,8 +1,10 @@ #include <ngx_config.h> + #include <ngx_string.h> #include <ngx_socket.h> #include <ngx_listen.h> +#include <ngx_inet.h> #include <ngx_http.h> #include <ngx_http_config.h> #include <ngx_http_core_module.h> @@ -324,7 +326,7 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy) ls->addr_text.len = ngx_snprintf(ls->addr_text.data + ngx_inet_ntop(AF_INET, - &in_addr[a].addr, + (char *) &in_addr[a].addr, ls->addr_text.data, INET_ADDRSTRLEN), 6, ":%d", in_port[p].port); @@ -345,6 +347,7 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy) ls->handler = ngx_http_init_connection; ls->log = cf->log; + ls->pool_size = ngx_http_connection_pool_size; ls->ctx = ctx; ls->servers = &in_port[p]; @@ -372,7 +375,7 @@ ngx_log_debug(cf->log, "port: %d" _ in_port[p].port); in_addr = (ngx_http_in_addr_t *) in_port[p].addr.elts; for (a = 0; a < in_port[p].addr.nelts; a++) { char ip[20]; - ngx_inet_ntop(AF_INET, &in_addr[a].addr, ip, 20); + ngx_inet_ntop(AF_INET, (char *) &in_addr[a].addr, ip, 20); ngx_log_debug(cf->log, "%s %08x" _ ip _ in_addr[a].core_srv_conf); } } diff --git a/src/http/ngx_http_event.c b/src/http/ngx_http_event.c index 26e67f8c8..6f7134a9e 100644 --- a/src/http/ngx_http_event.c +++ b/src/http/ngx_http_event.c @@ -16,12 +16,6 @@ #include <ngx_http_config.h> #include <ngx_http_core_module.h> -/* STUB */ -#include <ngx_http_output_filter.h> -int ngx_http_static_handler(ngx_http_request_t *r); -int ngx_http_index_handler(ngx_http_request_t *r); -int ngx_http_proxy_handler(ngx_http_request_t *r); -/**/ int ngx_http_init_connection(ngx_connection_t *c); @@ -41,13 +35,6 @@ static int ngx_http_keepalive_handler(ngx_event_t *ev); static int ngx_http_set_lingering_close(ngx_http_request_t *r); static int ngx_http_lingering_close_handler(ngx_event_t *ev); -#if 0 -int ngx_http_special_response(ngx_http_request_t *r, int error); -int ngx_http_redirect(ngx_http_request_t *r, int redirect); -int ngx_http_error(ngx_http_request_t *r, int error); -int ngx_http_close_request(ngx_http_request_t *r); -#endif - static int ngx_http_close_connection(ngx_event_t *ev); static size_t ngx_http_log_error(void *data, char *buf, size_t len); @@ -76,34 +63,23 @@ static ngx_http_header_t headers_in[] = { int ngx_http_init_connection(ngx_connection_t *c) { ngx_event_t *ev; - struct sockaddr *addr; ngx_http_log_ctx_t *ctx; ev = c->read; ev->event_handler = ngx_http_init_request; - ngx_test_null(c->pool, - ngx_create_pool(ngx_http_connection_pool_size, ev->log), - NGX_ERROR); - - ngx_test_null(c->requests, ngx_create_array(c->pool, 10, sizeof(char *)), - NGX_ERROR); - ev->close_handler = ngx_http_close_connection; c->write->close_handler = ngx_http_close_connection; - ngx_test_null(addr, ngx_palloc(c->pool, c->socklen), NGX_ERROR); - ngx_memcpy(addr, c->sockaddr, c->socklen); - c->sockaddr = addr; - ngx_test_null(c->addr_text.data, ngx_palloc(c->pool, c->addr_text_max_len), NGX_ERROR); - c->addr_text.len = ngx_inet_ntop(c->family, - (char *)c->sockaddr + c->addr, + c->addr_text.len = ngx_sock_ntop(c->family, c->sockaddr, c->addr_text.data, c->addr_text_max_len); - if (c->addr_text.len == 0) - return NGX_ERROR; + + if (c->addr_text.len == 0) { + return NGX_ERROR; + } ngx_test_null(ctx, ngx_pcalloc(c->pool, sizeof(ngx_http_log_ctx_t)), NGX_ERROR); @@ -133,6 +109,15 @@ int ngx_http_init_connection(ngx_connection_t *c) } #endif +#if (HAVE_EDGE_EVENT) + if (ngx_event_flags & NGX_HAVE_EDGE_EVENT) { + if (ngx_add_event(ev, NGX_READ_EVENT, NGX_EDGE_EVENT) == NGX_ERROR) { + return NGX_ERROR; + } + return ngx_http_init_request(ev); + } +#endif + #if (HAVE_AIO_EVENT) if (ngx_event_flags & NGX_HAVE_AIO_EVENT) { return ngx_http_init_request(ev); @@ -147,8 +132,9 @@ int ngx_http_init_connection(ngx_connection_t *c) static int ngx_http_init_request(ngx_event_t *ev) { - ngx_connection_t *c; - ngx_http_request_t *r; + ngx_connection_t *c; + ngx_http_request_t *r; + ngx_http_conf_ctx_t *ctx; c = (ngx_connection_t *) ev->data; c->sent = 0; @@ -179,6 +165,10 @@ static int ngx_http_init_request(ngx_event_t *ev) ngx_pcalloc(r->pool, sizeof(void *) * ngx_http_max_module), ngx_http_close_request(r)); + ctx = (ngx_http_conf_ctx_t *) c->ctx; + r->srv_conf = ctx->srv_conf; + r->loc_conf = ctx->loc_conf; + r->headers_out.headers = ngx_create_table(r->pool, 10); r->headers_out.content_length = -1; r->headers_out.last_modified_time = -1; @@ -195,7 +185,6 @@ static int ngx_http_process_request_header(ngx_event_t *ev) int n, rc; ngx_connection_t *c; ngx_http_request_t *r; - ngx_http_log_ctx_t *ctx; c = (ngx_connection_t *) ev->data; r = (ngx_http_request_t *) c->data; @@ -283,8 +272,7 @@ static int ngx_http_process_request_header(ngx_event_t *ev) static int ngx_http_process_request_line(ngx_http_request_t *r) { - int rc, len; - char **request; + int rc; ngx_connection_t *c; ngx_http_log_ctx_t *ctx; @@ -306,22 +294,6 @@ static int ngx_http_process_request_line(ngx_http_request_t *r) ngx_cpystrn(r->request_line.data, r->header_in->start, r->request_line.len + 1); - /* TEMP */ - ngx_test_null(request, ngx_push_array(c->requests), - ngx_http_close_request(r)); - - if (r->request_end) - len = r->request_end - r->header_in->start + 1; - else - len = 1; - c->requests_len += len; - ngx_test_null(*request, ngx_palloc(c->pool, len), - ngx_http_close_request(r)); - ngx_cpystrn(*request, r->header_in->start, len); - - ngx_log_debug(c->log, "REQ: '%s'" _ *request); - /* */ - if (r->uri_ext) { r->exten.len = (r->args_start ? r->args_start - 1 : r->uri_end) - r->uri_ext; @@ -764,13 +736,13 @@ static int ngx_http_lingering_close_handler(ngx_event_t *ev) ngx_log_debug(ev->log, "http lingering close handler"); + c = (ngx_connection_t *) ev->data; + r = (ngx_http_request_t *) c->data; + if (ev->timedout) { return ngx_http_close_request(r); } - c = (ngx_connection_t *) ev->data; - r = (ngx_http_request_t *) c->data; - timer = r->lingering_time - ngx_time(); if (timer <= 0) { return ngx_http_close_request(r); @@ -817,36 +789,8 @@ static int ngx_http_lingering_close_handler(ngx_event_t *ev) static int ngx_http_close_connection(ngx_event_t *ev) { - int i, len; - char **requests, *requests_line, *prev, *new; ngx_connection_t *c = (ngx_connection_t *) ev->data; - if (c->requests->nelts > 1) { - len = c->requests_len + c->requests->nelts * 2 - 1; - - ngx_test_null(requests_line, ngx_palloc(c->pool, len), - ngx_event_close_connection(ev)); - - requests = (char **) c->requests->elts; - prev = requests_line; - new = ngx_cpystrn(prev, requests[0], len); - len -= new - prev; - prev = new; - - for (i = 1; i < c->requests->nelts; i++) { - new = ngx_cpystrn(prev, ", ", len); - new = ngx_cpystrn(new, requests[i], len); - len -= new - prev; - prev = new; - } - - } else { - requests_line = * (char **) c->requests->elts; - } - - ngx_log_error(NGX_LOG_INFO, c->log, 0, - "REQUESTS: %d, '%s'", c->requests->nelts, requests_line); - return ngx_event_close_connection(ev); } diff --git a/src/http/ngx_http_get_time.c b/src/http/ngx_http_get_time.c index d03e8b16f..c83a5ba2a 100644 --- a/src/http/ngx_http_get_time.c +++ b/src/http/ngx_http_get_time.c @@ -5,7 +5,7 @@ #include <ngx_types.h> -ngx_http_get_time(char *buf, time_t t) +size_t ngx_http_get_time(char *buf, time_t t) { struct tm *tp; diff --git a/src/http/ngx_http_header_filter.c b/src/http/ngx_http_header_filter.c index 08369b7f3..282b82a78 100644 --- a/src/http/ngx_http_header_filter.c +++ b/src/http/ngx_http_header_filter.c @@ -70,7 +70,7 @@ static ngx_str_t http_codes[] = { static int ngx_http_header_filter(ngx_http_request_t *r) { - int len, status, i; + int len, status, i; time_t ims; ngx_hunk_t *h; ngx_chain_t *ch; @@ -106,6 +106,9 @@ static int ngx_http_header_filter(ngx_http_request_t *r) /* status line */ if (r->headers_out.status_line.len) { len += r->headers_out.status_line.len; +#if (NGX_SUPPRESS_WARN) + status = NGX_INVALID_ARRAY_INDEX; +#endif } else { if (r->headers_out.status < NGX_HTTP_MOVED_PERMANENTLY) { @@ -207,7 +210,8 @@ static int ngx_http_header_filter(ngx_http_request_t *r) /* 2^64 is 20 characters */ if (r->headers_out.content_length >= 0) { - h->last.mem += ngx_snprintf(h->last.mem, 49, "Content-Length: %u" CRLF, + h->last.mem += ngx_snprintf(h->last.mem, 49, + "Content-Length: " OFF_FMT CRLF, r->headers_out.content_length); } diff --git a/src/http/ngx_http_output_filter.c b/src/http/ngx_http_output_filter.c index 8b382e325..62756c89f 100644 --- a/src/http/ngx_http_output_filter.c +++ b/src/http/ngx_http_output_filter.c @@ -59,12 +59,11 @@ ngx_module_t ngx_http_output_filter_module = { int ngx_http_output_filter(ngx_http_request_t *r, ngx_hunk_t *hunk) { - int rc, once; - size_t size; - ssize_t n; - ngx_chain_t *ce; - ngx_http_output_filter_ctx_t *ctx; - ngx_http_output_filter_conf_t *conf; + int rc, once; + size_t size; + ngx_chain_t *ce; + ngx_http_output_filter_ctx_t *ctx; + ngx_http_output_filter_conf_t *conf; ctx = (ngx_http_output_filter_ctx_t *) ngx_http_get_module_ctx(r->main ? r->main : r, @@ -79,6 +78,10 @@ int ngx_http_output_filter(ngx_http_request_t *r, ngx_hunk_t *hunk) ctx->last = 1; } +#if (NGX_SUPPRESS_WARN) + rc = NGX_ALERT; +#endif + for (once = 1; once || ctx->in; once = 0) { /* input chain is not empty */ @@ -179,13 +182,12 @@ int ngx_http_output_filter(ngx_http_request_t *r, ngx_hunk_t *hunk) } else { if (ctx->hunk == NULL) { - if (hunk->type & NGX_HUNK_LAST) { - - conf = (ngx_http_output_filter_conf_t *) + conf = (ngx_http_output_filter_conf_t *) ngx_http_get_module_loc_conf( r->main ? r->main : r, ngx_http_output_filter_module); + if (hunk->type & NGX_HUNK_LAST) { size = hunk->last.mem - hunk->pos.mem; if (size > conf->hunk_size) { size = conf->hunk_size; @@ -243,6 +245,14 @@ int ngx_http_output_filter(ngx_http_request_t *r, ngx_hunk_t *hunk) ctx->hunk->pos.mem = ctx->hunk->last.mem = ctx->hunk->start; } +#if (NGX_SUPPRESS_WARN) + if (rc == NGX_ALERT) { + ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, + "ngx_http_output_filter: rc == NGX_ALERT"); + return NGX_ERROR; + } +#endif + if (rc == NGX_OK && ctx->last) { return NGX_OK; } diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c index a741f090f..f6d840903 100644 --- a/src/http/ngx_http_parse.c +++ b/src/http/ngx_http_parse.c @@ -304,6 +304,11 @@ printf("\nstate: %d, pos: %x, end: %x, char: '%c' buf: %s", return NGX_HTTP_PARSE_INVALID_REQUEST; } break; + +#if (NGX_SUPPRESS_WARN) + case sw_done: + break; +#endif } } @@ -490,6 +495,14 @@ printf("\nstate: %d, pos: %x, end: %x, char: '%c' buf: %s", return NGX_HTTP_PARSE_INVALID_HEADER; } break; + +#if (NGX_SUPPRESS_WARN) + case sw_done: + break; + + case sw_header_done: + break; +#endif } } diff --git a/src/http/ngx_http_parse_time.c b/src/http/ngx_http_parse_time.c index c236fd503..09e56b4f0 100644 --- a/src/http/ngx_http_parse_time.c +++ b/src/http/ngx_http_parse_time.c @@ -20,6 +20,11 @@ time_t ngx_http_parse_time(char *value, size_t len) fmt = 0; end = value + len; +#if (NGX_SUPPRESS_WARN) + day = 32; + year = 2038; +#endif + for (p = value; p < end; p++) { if (*p == ',') { break; |
