From 86de4cbef5f075840406e24e16a2b1417f721bb3 Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Thu, 30 Jan 2003 07:28:09 +0000 Subject: [PATCH] nginx-0.0.1-2003-01-30-10:28:09 import --- src/core/ngx_conf_file.c | 2 + src/core/ngx_config.h | 5 ++ src/core/ngx_connection.h | 8 +-- src/core/ngx_core.h | 1 + src/core/ngx_file.h | 2 +- src/core/ngx_inet.c | 26 +++++++- src/core/ngx_inet.h | 1 + src/core/ngx_listen.h | 1 + src/core/ngx_log.h | 2 +- src/event/ngx_event.c | 1 + src/event/ngx_event.h | 16 +++-- src/event/ngx_event_accept.c | 92 ++++++++++++++++---------- src/http/ngx_http.c | 7 +- src/http/ngx_http_event.c | 106 +++++++----------------------- src/http/ngx_http_get_time.c | 2 +- src/http/ngx_http_header_filter.c | 8 ++- src/http/ngx_http_output_filter.c | 28 +++++--- src/http/ngx_http_parse.c | 13 ++++ src/http/ngx_http_parse_time.c | 5 ++ src/os/unix/ngx_files.h | 10 +-- src/os/unix/ngx_types.h | 8 +++ src/os/win32/ngx_files.h | 8 +-- src/os/win32/ngx_types.h | 11 +++- 23 files changed, 211 insertions(+), 152 deletions(-) diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c index e11200114..8497e2d02 100644 --- a/src/core/ngx_conf_file.c +++ b/src/core/ngx_conf_file.c @@ -1,6 +1,8 @@ #include + #include +#include #include diff --git a/src/core/ngx_config.h b/src/core/ngx_config.h index 2797a8df3..a90a1dc4b 100644 --- a/src/core/ngx_config.h +++ b/src/core/ngx_config.h @@ -21,6 +21,11 @@ #define ngx_align(p) (char *) (((NGX_ALIGN_TYPE) p + NGX_ALIGN) & ~NGX_ALIGN) + +/* Platform specific: array[NGX_INVALID_ARRAY_INDEX] should cause SIGSEGV */ +#define NGX_INVALID_ARRAY_INDEX 0x80000000 + + #ifdef _WIN32 #define WIN32 1 diff --git a/src/core/ngx_connection.h b/src/core/ngx_connection.h index a94640d74..93f6cbdc3 100644 --- a/src/core/ngx_connection.h +++ b/src/core/ngx_connection.h @@ -19,10 +19,6 @@ struct ngx_connection_s { ngx_socket_t fd; void *data; - /* STUB */ - ngx_array_t *requests; - int requests_len; - #ifdef NGX_EVENT ngx_event_t *read; ngx_event_t *write; @@ -34,9 +30,11 @@ struct ngx_connection_s { void *ctx; ngx_server_t *servers; - ngx_pool_t *pool; ngx_log_t *log; + ngx_pool_t *pool; + int pool_size; + int family; struct sockaddr *sockaddr; socklen_t socklen; diff --git a/src/core/ngx_core.h b/src/core/ngx_core.h index adab5018c..8170f858d 100644 --- a/src/core/ngx_core.h +++ b/src/core/ngx_core.h @@ -8,6 +8,7 @@ #define NGX_AGAIN -2 #define NGX_WAITING -3 #define NGX_DECLINED -4 +#define NGX_ALERT -5 #define NGX_MAXHOSTNAMELEN 32 diff --git a/src/core/ngx_file.h b/src/core/ngx_file.h index e827aff0e..c1bb3c2f3 100644 --- a/src/core/ngx_file.h +++ b/src/core/ngx_file.h @@ -2,7 +2,7 @@ #define _NGX_FILE_H_INCLUDED_ -#include +#include #include #include diff --git a/src/core/ngx_inet.c b/src/core/ngx_inet.c index aba990b41..b566e1a25 100644 --- a/src/core/ngx_inet.c +++ b/src/core/ngx_inet.c @@ -4,10 +4,34 @@ #include +/* AF_INET only */ + +size_t ngx_sock_ntop(int family, struct sockaddr *addr, char *text, size_t len) +{ + char *p; + struct sockaddr_in *addr_in; + + if (family != AF_INET) { + return 0; + } + + addr_in = (struct sockaddr_in *) addr; + p = (char *) &addr_in->sin_addr; + + return ngx_snprintf(text, len > INET_ADDRSTRLEN ? INET_ADDRSTRLEN : len, + "%u.%u.%u.%u", + (unsigned char) p[0], + (unsigned char) p[1], + (unsigned char) p[2], + (unsigned char) p[3]); +} + + size_t ngx_inet_ntop(int family, char *addr, char *text, size_t len) { - if (family != AF_INET) + if (family != AF_INET) { return 0; + } return ngx_snprintf(text, len > INET_ADDRSTRLEN ? INET_ADDRSTRLEN : len, "%u.%u.%u.%u", diff --git a/src/core/ngx_inet.h b/src/core/ngx_inet.h index 0766d1fac..9f714441f 100644 --- a/src/core/ngx_inet.h +++ b/src/core/ngx_inet.h @@ -2,6 +2,7 @@ #define _NGX_INET_H_INCLUDED_ +size_t ngx_sock_ntop(int family, struct sockaddr *addr, char *text, size_t len); size_t ngx_inet_ntop(int family, char *addr, char *text, size_t len); diff --git a/src/core/ngx_listen.h b/src/core/ngx_listen.h index 91f39ad74..61f08fdee 100644 --- a/src/core/ngx_listen.h +++ b/src/core/ngx_listen.h @@ -28,6 +28,7 @@ typedef struct { void *servers; /* array of ngx_http_in_addr_t, for example */ ngx_log_t *log; + int pool_size; int backlog; time_t post_accept_timeout; /* should be here because diff --git a/src/core/ngx_log.h b/src/core/ngx_log.h index d79237ef0..c7b780fdd 100644 --- a/src/core/ngx_log.h +++ b/src/core/ngx_log.h @@ -2,8 +2,8 @@ #define _NGX_LOG_H_INCLUDED_ +#include #include -#include typedef enum { NGX_LOG_EMERG = 0, diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c index 04036d430..63cf999cd 100644 --- a/src/event/ngx_event.c +++ b/src/event/ngx_event.c @@ -120,6 +120,7 @@ void ngx_pre_thread(ngx_array_t *ls, ngx_pool_t *pool, ngx_log_t *log) c->ctx = s[i].ctx; c->servers = s[i].servers; c->log = s[i].log; + c->pool_size = s[i].pool_size; ngx_test_null(ev->log, ngx_palloc(pool, sizeof(ngx_log_t)), /* void */ ; ); diff --git a/src/event/ngx_event.h b/src/event/ngx_event.h index 71895a0be..a91881067 100644 --- a/src/event/ngx_event.h +++ b/src/event/ngx_event.h @@ -111,13 +111,19 @@ typedef struct { /* Event filter requires to read/write the whole data - select, poll, /dev/poll, kqueue. */ #define NGX_HAVE_LEVEL_EVENT 1 -/* Event filter deleted after notification - select, poll, kqueue. - /dev/poll, epoll implemetned with additional syscall */ + +/* Event filter is deleted after notification - select, poll, kqueue. + Using /dev/poll, epoll it can be implemented with additional syscall */ #define NGX_HAVE_ONESHOT_EVENT 2 -/* Event filter notify only changes - kqueue, epoll */ + +/* Event filter notifies only changes and initial level - kqueue */ #define NGX_HAVE_CLEAR_EVENT 4 -/* No nedd to add or delete event filters - overlapped, aio_read, aioread */ -#define NGX_HAVE_AIO_EVENT 8 + +/* Event filter notifies only changes (edgesi) but not initial level - epoll */ +#define NGX_HAVE_EDGE_EVENT 8 + +/* No need to add or delete event filters - overlapped, aio_read, aioread */ +#define NGX_HAVE_AIO_EVENT 16 /* Event filter is deleted before closing file. Has no meaning for select, poll, epoll. diff --git a/src/event/ngx_event_accept.c b/src/event/ngx_event_accept.c index 73d83e64a..14422afdf 100644 --- a/src/event/ngx_event_accept.c +++ b/src/event/ngx_event_accept.c @@ -11,40 +11,55 @@ #include +/* This function should always return NGX_OK even there are some failures + because if we return NGX_ERROR then listening socket would be closed */ + int ngx_event_accept(ngx_event_t *ev) { + socklen_t len; + struct sockaddr *sa; ngx_err_t err; + ngx_pool_t *pool; ngx_socket_t s; ngx_event_t *rev, *wev; - ngx_connection_t *c, *ac; + ngx_connection_t *c, *ls; + + ls = (ngx_connection_t *) ev->data; - ac = (ngx_connection_t *) ev->data; - ngx_log_debug(ev->log, "ngx_event_accept: accept ready: %d" _ ev->available); - + ev->ready = 0; - + +/* DEBUG */ ev->available++; + do { - if ((s = accept(ac->fd, ac->sockaddr, &ac->socklen)) == -1) { + ngx_test_null(pool, ngx_create_pool(ls->pool_size, ev->log), NGX_OK); + + ngx_test_null(sa, ngx_palloc(pool, ls->socklen), NGX_OK); + len = ls->socklen; + + s = accept(ls->fd, sa, &len); + if (s == -1) { err = ngx_socket_errno; + ngx_destroy_pool(pool); + if (err == NGX_EAGAIN) { - ngx_log_error(NGX_LOG_INFO, ev->log, err, - "ngx_event_accept: EAGAIN while accept %s", - ac->addr_text); + ngx_log_error(NGX_LOG_NOTICE, ev->log, err, + "EAGAIN while accept %s", ls->addr_text.data); return NGX_OK; } - ngx_log_error(NGX_LOG_ERR, ev->log, err, - "ngx_event_accept: accept %s failed", ac->addr_text); - /* if we return NGX_ERROR listen socket would be closed */ + ngx_log_error(NGX_LOG_ALERT, ev->log, err, + "accept %s failed", ls->addr_text.data); return NGX_OK; } #if !(HAVE_INHERITED_NONBLOCK) - if (ngx_nonblocking(s) == -1) - ngx_log_error(NGX_LOG_ERR, ev->log, ngx_socket_errno, - ngx_nonblocking_n "failed"); + if (ngx_nonblocking(s) == -1) { + ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_socket_errno, + ngx_nonblocking_n " %s failed", ls->addr_text.data); + } #endif rev = &ngx_read_events[s]; @@ -55,12 +70,14 @@ int ngx_event_accept(ngx_event_t *ev) ngx_memzero(wev, sizeof(ngx_event_t)); ngx_memzero(c, sizeof(ngx_connection_t)); - c->sockaddr = ac->sockaddr; - c->family = ac->family; - c->socklen = ac->socklen; - c->addr = ac->addr; - c->addr_text_max_len = ac->addr_text_max_len; - c->post_accept_timeout = ac->post_accept_timeout; + c->pool = pool; + + c->sockaddr = sa; + c->family = ls->family; + c->socklen = len; + c->addr = ls->addr; + c->addr_text_max_len = ls->addr_text_max_len; + c->post_accept_timeout = ls->post_accept_timeout; rev->index = wev->index = NGX_INVALID_INDEX; @@ -77,30 +94,39 @@ int ngx_event_accept(ngx_event_t *ev) wev->timer_handler = rev->timer_handler = ngx_event_close_connection; wev->close_handler = rev->close_handler = ngx_event_close_connection; - c->ctx = ac->ctx; - c->servers = ac->servers; - c->log = rev->log = wev->log = ev->log; + c->ctx = ls->ctx; + c->servers = ls->servers; - /* STUB: x86: SP: xadd, MT: lock xadd, MP: lock xadd, shared */ + ngx_test_null(c->log, ngx_palloc(c->pool, sizeof(ngx_log_t)), NGX_OK); + ngx_memcpy(c->log, ev->log, sizeof(ngx_log_t)); + rev->log = wev->log = c->log; + + /* STUB: x86: SP: xadd ?, MT: lock xadd, MP: lock xadd, shared */ c->number = ngx_connection_counter++; ngx_log_debug(ev->log, "ngx_event_accept: accept: %d, %d" _ - s _ c->number); + s _ c->number); #if (HAVE_DEFERRED_ACCEPT) - if (ev->accept_filter) + if (ev->accept_filter) { rev->ready = 1; + } #endif - ac->handler(c); + ls->handler(c); -#if (HAVE_KQUEUE) -#if !(USE_KQUEUE) - if (ngx_event_type == NGX_KQUEUE_EVENT) -#endif +#if (USE_KQUEUE) + + ev->available--; + +#elif (HAVE_KQUEUE) + + if (ngx_event_type == NGX_KQUEUE_EVENT) { ev->available--; + } + #endif } while (ev->available); - return 0; + return NGX_OK; } 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 + #include #include #include +#include #include #include #include @@ -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 #include -/* STUB */ -#include -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_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; diff --git a/src/os/unix/ngx_files.h b/src/os/unix/ngx_files.h index f0c324e40..d35382f6c 100644 --- a/src/os/unix/ngx_files.h +++ b/src/os/unix/ngx_files.h @@ -2,14 +2,15 @@ #define _NGX_FILES_H_INCLUDED_ -#include -#include +#include + +#include +#include + -typedef int ngx_fd_t; #define NGX_INVALID_FILE -1 #define NGX_FILE_ERROR -1 -typedef struct stat ngx_file_info_t; #define ngx_open_file open @@ -18,6 +19,7 @@ typedef struct stat ngx_file_info_t; #define ngx_close_file close #define ngx_close_file_n "close()" +ssize_t ngx_read_file(ngx_file_t *file, char *buf, size_t size, off_t offset); #define ngx_read_file_n "read()" #define NGX_FILE_RDONLY O_RDONLY diff --git a/src/os/unix/ngx_types.h b/src/os/unix/ngx_types.h index 9919e90c4..bf61ae2d9 100644 --- a/src/os/unix/ngx_types.h +++ b/src/os/unix/ngx_types.h @@ -4,6 +4,14 @@ #include +#include +#include + + +typedef int ngx_fd_t; +typedef struct stat ngx_file_info_t; + + #ifdef SOLARIS diff --git a/src/os/win32/ngx_files.h b/src/os/win32/ngx_files.h index f5e50cc9f..a8970a2fd 100644 --- a/src/os/win32/ngx_files.h +++ b/src/os/win32/ngx_files.h @@ -4,19 +4,18 @@ #include +#include +#include + /* INVALID_FILE_ATTRIBUTES specified but never defined at least in VC6SP2 */ #ifndef INVALID_FILE_ATTRIBUTES #define INVALID_FILE_ATTRIBUTES 0xFFFFFFFF #endif -typedef HANDLE ngx_fd_t; #define NGX_INVALID_FILE INVALID_HANDLE_VALUE #define NGX_FILE_ERROR 0 -typedef unsigned __int64 off_t; - -typedef BY_HANDLE_FILE_INFORMATION ngx_file_info_t; #define ngx_open_file(name, flags) \ @@ -56,6 +55,7 @@ int ngx_file_type(char *filename, ngx_file_info_t *fi); - 116444736000000000) / 10000000) +ssize_t ngx_read_file(ngx_file_t *file, char *buf, size_t size, off_t offset); #define ngx_read_file_n "ReadFile()" diff --git a/src/os/win32/ngx_types.h b/src/os/win32/ngx_types.h index c9e7415f2..d5f0d927d 100644 --- a/src/os/win32/ngx_types.h +++ b/src/os/win32/ngx_types.h @@ -5,10 +5,15 @@ #include -typedef int ssize_t; -typedef long time_t; +typedef unsigned __int32 u_int32_t; + +typedef int ssize_t; +typedef long time_t; + +typedef HANDLE ngx_fd_t; +typedef unsigned __int64 off_t; +typedef BY_HANDLE_FILE_INFORMATION ngx_file_info_t; -typedef unsigned __int32 u_int32_t;