diff options
Diffstat (limited to 'src/http')
| -rw-r--r-- | src/http/modules/ngx_http_userid_filter.c | 3 | ||||
| -rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_handler.c | 4 | ||||
| -rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_handler.h | 2 | ||||
| -rw-r--r-- | src/http/ngx_http.c | 42 | ||||
| -rw-r--r-- | src/http/ngx_http_core_module.c | 12 | ||||
| -rw-r--r-- | src/http/ngx_http_core_module.h | 4 | ||||
| -rw-r--r-- | src/http/ngx_http_parse.c | 1 | ||||
| -rw-r--r-- | src/http/ngx_http_request.c | 101 |
8 files changed, 18 insertions, 151 deletions
diff --git a/src/http/modules/ngx_http_userid_filter.c b/src/http/modules/ngx_http_userid_filter.c index 718cca7e2..e37accf8f 100644 --- a/src/http/modules/ngx_http_userid_filter.c +++ b/src/http/modules/ngx_http_userid_filter.c @@ -281,7 +281,6 @@ static ngx_int_t ngx_http_userid_set_uid(ngx_http_request_t *r, size_t len; socklen_t slen; struct sockaddr_in addr_in; - uint32_t service; ngx_str_t src, dst; ngx_table_elt_t *set_cookie; @@ -542,7 +541,7 @@ char *ngx_conf_check_domain(ngx_conf_t *cf, void *post, void *data) if (domain->len == 4 && ngx_strcmp(domain->data, "none") == 0) { domain->len = 1; - domain->data = "."; + domain->data = (u_char *) "."; } return NGX_CONF_OK; diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c index 711aad2f4..af9760c2e 100644 --- a/src/http/modules/proxy/ngx_http_proxy_handler.c +++ b/src/http/modules/proxy/ngx_http_proxy_handler.c @@ -1234,7 +1234,7 @@ static char *ngx_http_proxy_parse_upstream(ngx_str_t *url, u->default_port = 1; } - u->port = htons((u_short) u->port); + u->port = htons(u->port); return NULL; } } @@ -1265,7 +1265,7 @@ static char *ngx_http_proxy_parse_upstream(ngx_str_t *url, if (u->port_text.len > 0) { u->port = ngx_atoi(u->port_text.data, u->port_text.len); if (u->port > 0) { - u->port = htons((u_short) u->port); + u->port = htons(u->port); return NULL; } } diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.h b/src/http/modules/proxy/ngx_http_proxy_handler.h index 6e3725899..27799bbb9 100644 --- a/src/http/modules/proxy/ngx_http_proxy_handler.h +++ b/src/http/modules/proxy/ngx_http_proxy_handler.h @@ -41,7 +41,7 @@ typedef struct { ngx_str_t port_text; ngx_str_t *location; - ngx_int_t port; + in_port_t port; unsigned default_port:1; } ngx_http_proxy_upstream_conf_t; diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c index fabb2dd05..d02b2503a 100644 --- a/src/http/ngx_http.c +++ b/src/http/ngx_http.c @@ -500,48 +500,12 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) in_addr = in_port[p].addrs.elts; while (a < in_port[p].addrs.nelts) { - if (!(ls = ngx_push_array(&cf->cycle->listening))) { + ls = ngx_listening_inet_stream_socket(cf, in_addr[a].addr, + in_port[p].port); + if (ls == NULL) { return NGX_CONF_ERROR; } - ngx_memzero(ls, sizeof(ngx_listening_t)); - - addr_in = ngx_pcalloc(cf->pool, sizeof(struct sockaddr_in)); - if (addr_in == NULL) { - return NGX_CONF_ERROR; - } - -#if (HAVE_SIN_LEN) - addr_in->sin_len = sizeof(struct sockaddr_in); -#endif - addr_in->sin_family = AF_INET; - addr_in->sin_addr.s_addr = in_addr[a].addr; - addr_in->sin_port = htons((u_short) in_port[p].port); - - ls->addr_text.data = ngx_palloc(cf->pool, INET_ADDRSTRLEN + 6); - if (ls->addr_text.data == NULL) { - return NGX_CONF_ERROR; - } - - ls->addr_text.len = ngx_inet_ntop(AF_INET, &in_addr[a].addr, - ls->addr_text.data, - INET_ADDRSTRLEN), - - ls->addr_text.len += ngx_snprintf((char *) ls->addr_text.data - + ls->addr_text.len, - 6, ":%d", in_port[p].port); - - ls->fd = (ngx_socket_t) -1; - ls->family = AF_INET; - ls->type = SOCK_STREAM; - ls->protocol = IPPROTO_IP; -#if (WIN32) - ls->flags = WSA_FLAG_OVERLAPPED; -#endif - ls->sockaddr = (struct sockaddr *) addr_in; - ls->socklen = sizeof(struct sockaddr_in); - ls->addr = offsetof(struct sockaddr_in, sin_addr); - ls->addr_text_max_len = INET_ADDRSTRLEN; ls->backlog = -1; #if 0 #if 0 diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index 78bb2a737..6c4f819b9 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -1473,7 +1473,8 @@ static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) ngx_http_core_srv_conf_t *scf = conf; u_char *addr; - u_int p; + ngx_int_t port; + ngx_uint_t p; struct hostent *h; ngx_str_t *args; ngx_http_listen_t *ls; @@ -1505,14 +1506,14 @@ static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) p = 0; } - ls->port = ngx_atoi(&addr[p], args[1].len - p); - if (ls->port == NGX_ERROR && p == 0) { + port = ngx_atoi(&addr[p], args[1].len - p); + if (port == NGX_ERROR && p == 0) { /* "listen host" */ ls->port = 80; - } else if ((ls->port == NGX_ERROR && p != 0) /* "listen host:NONNUMBER" */ - || (ls->port < 1 || ls->port > 65536)) { /* "listen 99999" */ + } else if ((port == NGX_ERROR && p != 0) /* "listen host:NONNUMBER" */ + || (port < 1 || port > 65536)) { /* "listen 99999" */ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid port \"%s\" in \"%s\" directive, " @@ -1523,6 +1524,7 @@ static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) } else if (p == 0) { ls->addr = INADDR_ANY; + ls->port = (in_port_t) port; return NGX_CONF_OK; } diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h index 6c0e7a1b0..25101aa7c 100644 --- a/src/http/ngx_http_core_module.h +++ b/src/http/ngx_http_core_module.h @@ -9,7 +9,7 @@ typedef struct { in_addr_t addr; - int port; + in_port_t port; int family; ngx_str_t file_name; int line; @@ -78,7 +78,7 @@ typedef struct { /* list of structures to find core_srv_conf quickly at run time */ typedef struct { - int port; + in_port_t port; ngx_str_t port_name; ngx_array_t addrs; /* array of ngx_http_in_addr_t */ } ngx_http_in_port_t; diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c index 76fbb8006..8136f31d3 100644 --- a/src/http/ngx_http_parse.c +++ b/src/http/ngx_http_parse.c @@ -3,6 +3,7 @@ #include <ngx_core.h> #include <ngx_http.h> + ngx_int_t ngx_http_parse_request_line(ngx_http_request_t *r) { u_char ch, *p, *m; diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c index 52c7c4256..dcf53d746 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -1899,109 +1899,10 @@ void ngx_ssl_close_handler(ngx_event_t *ev) void ngx_http_close_connection(ngx_connection_t *c) { - ngx_socket_t fd; - ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, "close http connection: %d", c->fd); - if (c->pool == NULL) { - ngx_log_error(NGX_LOG_ALERT, c->log, 0, "connection already closed"); - return; - } - -#if (NGX_HTTP_SSL) - - if (c->ssl) { - if (ngx_ssl_shutdown(c) == NGX_AGAIN) { - c->read->event_handler = ngx_ssl_close_handler; - c->write->event_handler = ngx_ssl_close_handler; - return; - } - } - -#endif - - if (c->read->timer_set) { - ngx_del_timer(c->read); - } - - if (c->write->timer_set) { - ngx_del_timer(c->write); - } - - if (ngx_del_conn) { - ngx_del_conn(c, NGX_CLOSE_EVENT); - - } else { - if (c->read->active || c->read->disabled) { - ngx_del_event(c->read, NGX_READ_EVENT, NGX_CLOSE_EVENT); - } - - if (c->write->active || c->write->disabled) { - ngx_del_event(c->write, NGX_WRITE_EVENT, NGX_CLOSE_EVENT); - } - } - - /* - * we have to clean the connection information before the closing - * because another thread may reopen the same file descriptor - * before we clean the connection - */ - -#if (NGX_THREADS) - - if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_OK) { - - if (c->read->prev) { - ngx_delete_posted_event(c->read); - } - - if (c->write->prev) { - ngx_delete_posted_event(c->write); - } - - c->read->closed = 1; - c->write->closed = 1; - - if (c->single_connection) { - ngx_unlock(&c->lock); - c->read->locked = 0; - c->write->locked = 0; - } - - ngx_mutex_unlock(ngx_posted_events_mutex); - } - -#else - - if (c->read->prev) { - ngx_delete_posted_event(c->read); - } - - if (c->write->prev) { - ngx_delete_posted_event(c->write); - } - - c->read->closed = 1; - c->write->closed = 1; - -#endif - - fd = c->fd; - c->fd = (ngx_socket_t) -1; - c->data = NULL; - - ngx_destroy_pool(c->pool); - - if (ngx_close_socket(fd) == -1) { - - /* we use ngx_cycle->log because c->log was in c->pool */ - - ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, ngx_socket_errno, - ngx_close_socket_n " failed"); - } - - return; + ngx_close_connection(c); } |
