diff options
Diffstat (limited to '')
| -rw-r--r-- | src/http/modules/ngx_http_index_handler.c | 4 | ||||
| -rw-r--r-- | src/http/ngx_http.c | 36 | ||||
| -rw-r--r-- | src/http/ngx_http_core_module.c | 92 | ||||
| -rw-r--r-- | src/http/ngx_http_header_filter.c | 10 | ||||
| -rw-r--r-- | src/http/ngx_http_output_filter.c | 8 | ||||
| -rw-r--r-- | src/http/ngx_http_special_response.c | 6 |
6 files changed, 83 insertions, 73 deletions
diff --git a/src/http/modules/ngx_http_index_handler.c b/src/http/modules/ngx_http_index_handler.c index 0286669f2..c9ad91112 100644 --- a/src/http/modules/ngx_http_index_handler.c +++ b/src/http/modules/ngx_http_index_handler.c @@ -14,7 +14,7 @@ static char *ngx_http_index_set_index(ngx_conf_t *cf, ngx_command_t *cmd, static ngx_command_t ngx_http_index_commands[] = { {ngx_string("index"), - NGX_HTTP_LOC_CONF|NGX_CONF_ANY, + NGX_HTTP_LOC_CONF|NGX_CONF_ANY1, ngx_http_index_set_index, NGX_HTTP_LOC_CONF_OFFSET, 0, @@ -280,7 +280,7 @@ static char *ngx_http_index_set_index(ngx_conf_t *cf, ngx_command_t *cmd, for (i = 1; i < cf->args->nelts; i++) { if (value[i].len == 0) { ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1, - "index \"%s\" is invalid", value[1].data); + "index \"%s\" is invalid", value[i].data); return ngx_conf_errstr; } diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c index efa2bec68..5612d6367 100644 --- a/src/http/ngx_http.c +++ b/src/http/ngx_http.c @@ -151,14 +151,14 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) and its location{}s' loc_conf's */ cmcf = ctx->main_conf[ngx_http_core_module.ctx_index]; - cscfp = (ngx_http_core_srv_conf_t **)cmcf->servers.elts; + cscfp = cmcf->servers.elts; for (m = 0; ngx_modules[m]; m++) { if (ngx_modules[m]->type != NGX_HTTP_MODULE) { continue; } - module = (ngx_http_module_t *) ngx_modules[m]->ctx; + module = ngx_modules[m]->ctx; mi = ngx_modules[m]->ctx_index; /* init http{} main_conf's */ @@ -227,18 +227,18 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) NGX_CONF_ERROR); /* "server" directives */ - cscfp = (ngx_http_core_srv_conf_t **) cmcf->servers.elts; + cscfp = cmcf->servers.elts; for (s = 0; s < cmcf->servers.nelts; s++) { /* "listen" directives */ - lscf = (ngx_http_listen_t *) cscfp[s]->listen.elts; + lscf = cscfp[s]->listen.elts; for (l = 0; l < cscfp[s]->listen.nelts; l++) { port_found = 0; /* AF_INET only */ - in_port = (ngx_http_in_port_t *) in_ports.elts; + in_port = in_ports.elts; for (p = 0; p < in_ports.nelts; p++) { if (lscf[l].port == in_port[p].port) { @@ -248,7 +248,7 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) port_found = 1; addr_found = 0; - in_addr = (ngx_http_in_addr_t *) in_port[p].addrs.elts; + in_addr = in_port[p].addrs.elts; for (a = 0; a < in_port[p].addrs.nelts; a++) { if (lscf[l].addr == in_addr[a].addr) { @@ -256,8 +256,7 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) /* the address is already bound to this port */ /* "server_name" directives */ - s_name = (ngx_http_server_name_t *) - cscfp[s]->server_names.elts; + s_name = cscfp[s]->server_names.elts; for (n = 0; n < cscfp[s]->server_names.nelts; n++) { /* add the server name and server core module @@ -394,17 +393,17 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) /* AF_INET only */ - in_port = (ngx_http_in_port_t *) in_ports.elts; + in_port = in_ports.elts; for (p = 0; p < in_ports.nelts; p++) { /* check whether the all server names point to the same server */ - in_addr = (ngx_http_in_addr_t *) in_port[p].addrs.elts; + in_addr = in_port[p].addrs.elts; for (a = 0; a < in_port[p].addrs.nelts; a++) { virtual_names = 0; - name = (ngx_http_server_name_t *) in_addr[a].names.elts; + name = in_addr[a].names.elts; for (n = 0; n < in_addr[a].names.nelts; n++) { if (in_addr[a].core_srv_conf != name[n].core_srv_conf) { virtual_names = 1; @@ -430,7 +429,7 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) a = 0; } - in_addr = (ngx_http_in_addr_t *) in_port[p].addrs.elts; + in_addr = in_port[p].addrs.elts; while (a < in_port[p].addrs.nelts) { ngx_test_null(ls, ngx_push_array(&ngx_listening_sockets), @@ -443,7 +442,7 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) addr_in->sin_family = AF_INET; addr_in->sin_addr.s_addr = in_addr[a].addr; - addr_in->sin_port = htons(in_port[p].port); + addr_in->sin_port = htons((u_short) in_port[p].port); ngx_test_null(ls->addr_text.data, ngx_palloc(cf->pool, INET_ADDRSTRLEN + 6), @@ -478,7 +477,7 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) if (in_port[p].addrs.nelts > 1) { - in_addr = (ngx_http_in_addr_t *) in_port[p].addrs.elts; + in_addr = in_port[p].addrs.elts; if (in_addr[in_port[p].addrs.nelts - 1].addr != INADDR_ANY) { /* if this port has not the "*:port" binding then create @@ -523,14 +522,19 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) } /* DEBUG STUFF */ - in_port = (ngx_http_in_port_t *) in_ports.elts; + in_port = in_ports.elts; for (p = 0; p < in_ports.nelts; p++) { ngx_log_debug(cf->log, "port: %d" _ in_port[p].port); - in_addr = (ngx_http_in_addr_t *) in_port[p].addrs.elts; + in_addr = in_port[p].addrs.elts; for (a = 0; a < in_port[p].addrs.nelts; a++) { char 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); + s_name = in_addr[a].names.elts; + for (n = 0; n < in_addr[a].names.nelts; n++) { +ngx_log_debug(cf->log, "%s %08x" _ s_name[n].name.data _ + s_name[n].core_srv_conf); + } } } /**/ diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index b67866961..46f9686e3 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -32,6 +32,7 @@ static int ngx_cmp_locations(const void *first, const void *second); static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy); static char *ngx_types_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); +static char *ngx_set_type(ngx_conf_t *cf, ngx_command_t *dummy, void *conf); static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); static char *ngx_set_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); @@ -103,7 +104,7 @@ static ngx_command_t ngx_http_core_commands[] = { NULL}, {ngx_string("server_name"), - NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_ANY, + NGX_HTTP_SRV_CONF|NGX_CONF_ANY1, ngx_set_server_name, NGX_HTTP_SRV_CONF_OFFSET, 0, @@ -281,8 +282,6 @@ int ngx_http_core_translate_handler(ngx_http_request_t *r) char *location, *last; ngx_err_t err; ngx_table_elt_t *h; - ngx_http_in_port_t *in_port; - ngx_http_server_name_t *s_name; ngx_http_core_srv_conf_t *cscf; ngx_http_core_loc_conf_t *clcf; @@ -669,9 +668,24 @@ static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy) } -static char *ngx_set_type(ngx_conf_t *cf, ngx_command_t *dummy, char *conf) +static char *ngx_types_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { - ngx_http_core_loc_conf_t *lcf = (ngx_http_core_loc_conf_t *) conf; + char *rv; + ngx_conf_t pcf; + + pcf = *cf; + cf->handler = ngx_set_type; + cf->handler_conf = conf; + rv = ngx_conf_parse(cf, NULL); + *cf = pcf; + + return rv; +} + + +static char *ngx_set_type(ngx_conf_t *cf, ngx_command_t *dummy, void *conf) +{ + ngx_http_core_loc_conf_t *lcf = conf; int i, key; ngx_str_t *args; @@ -705,21 +719,6 @@ static char *ngx_set_type(ngx_conf_t *cf, ngx_command_t *dummy, char *conf) } -static char *ngx_types_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) -{ - char *rv; - ngx_conf_t pcf; - - pcf = *cf; - cf->handler = ngx_set_type; - cf->handler_conf = conf; - rv = ngx_conf_parse(cf, NULL); - *cf = pcf; - - return rv; -} - - static void *ngx_http_core_create_main_conf(ngx_pool_t *pool) { ngx_http_core_main_conf_t *cmcf; @@ -775,9 +774,10 @@ static void *ngx_http_core_create_srv_conf(ngx_pool_t *pool) static char *ngx_http_core_merge_srv_conf(ngx_pool_t *pool, void *parent, void *child) { - ngx_http_core_srv_conf_t *prev = (ngx_http_core_srv_conf_t *) parent; - ngx_http_core_srv_conf_t *conf = (ngx_http_core_srv_conf_t *) child; + ngx_http_core_srv_conf_t *prev = parent; + ngx_http_core_srv_conf_t *conf = child; + int len; ngx_err_t err; ngx_http_listen_t *l; ngx_http_server_name_t *n; @@ -798,9 +798,12 @@ static char *ngx_http_core_merge_srv_conf(ngx_pool_t *pool, if (gethostname(n->name.data, NGX_MAXHOSTNAMELEN) == -1) { err = ngx_errno; - ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1, - "gethostname() failed (%d: %s)", - err, ngx_strerror(err)); + len = ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1, + "gethostname() failed (%d: ", err); + len += ngx_strerror_r(err, ngx_conf_errstr + len, + sizeof(ngx_conf_errstr) - len - 1); + ngx_conf_errstr[len++] = ')'; + ngx_conf_errstr[len++] = '\0'; return ngx_conf_errstr; } @@ -862,8 +865,8 @@ static ngx_http_type_t default_types[] = { static char *ngx_http_core_merge_loc_conf(ngx_pool_t *pool, void *parent, void *child) { - ngx_http_core_loc_conf_t *prev = (ngx_http_core_loc_conf_t *) parent; - ngx_http_core_loc_conf_t *conf = (ngx_http_core_loc_conf_t *) child; + ngx_http_core_loc_conf_t *prev = parent; + ngx_http_core_loc_conf_t *conf = child; int i, key; ngx_http_type_t *t; @@ -919,7 +922,7 @@ static char *ngx_http_core_merge_loc_conf(ngx_pool_t *pool, static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { - ngx_http_core_srv_conf_t *scf = (ngx_http_core_srv_conf_t *) conf; + ngx_http_core_srv_conf_t *scf = conf; char *addr; u_int p; @@ -963,11 +966,11 @@ static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) } else if ((ls->port == NGX_ERROR && p != 0) /* "listen host:NONNUMBER" */ || (ls->port < 1 || ls->port > 65536)) { /* "listen 99999" */ - ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1, - "invalid port \"%s\", " - "it must be a number between 1 and 65535", - &addr[p]); - return ngx_conf_errstr; + ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1, + "invalid port \"%s\", " + "it must be a number between 1 and 65535", + &addr[p]); + return ngx_conf_errstr; } else if (p == 0) { ls->addr = INADDR_ANY; @@ -993,21 +996,30 @@ static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) static char *ngx_set_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { - ngx_http_core_srv_conf_t *scf = (ngx_http_core_srv_conf_t *) conf; + ngx_http_core_srv_conf_t *scf = conf; - ngx_str_t *args; + int i; + ngx_str_t *value; ngx_http_server_name_t *sn; /* TODO: several names */ /* TODO: warn about duplicate 'server_name' directives */ - ngx_test_null(sn, ngx_push_array(&scf->server_names), NGX_CONF_ERROR); + value = cf->args->elts; - args = cf->args->elts; + for (i = 1; i < cf->args->nelts; i++) { + if (value[i].len == 0) { + ngx_snprintf(ngx_conf_errstr, sizeof(ngx_conf_errstr) - 1, + "server name \"%s\" is invalid", value[i].data); + return ngx_conf_errstr; + } - sn->name.len = args[1].len; - sn->name.data = args[1].data; - sn->core_srv_conf = scf; + ngx_test_null(sn, ngx_push_array(&scf->server_names), NGX_CONF_ERROR); + + sn->name.len = value[i].len; + sn->name.data = value[i].data; + sn->core_srv_conf = scf; + } return NGX_CONF_OK; } diff --git a/src/http/ngx_http_header_filter.c b/src/http/ngx_http_header_filter.c index fd26fedde..cbdbf23df 100644 --- a/src/http/ngx_http_header_filter.c +++ b/src/http/ngx_http_header_filter.c @@ -1,16 +1,10 @@ -#include <nginx.h> - #include <ngx_config.h> - #include <ngx_core.h> -#include <ngx_string.h> -#include <ngx_table.h> -#include <ngx_hunk.h> -#include <ngx_conf_file.h> + +#include <nginx.h> #include <ngx_http.h> -#include <ngx_http_config.h> #include <ngx_http_write_filter.h> diff --git a/src/http/ngx_http_output_filter.c b/src/http/ngx_http_output_filter.c index 0d91e1bf3..2db9b523f 100644 --- a/src/http/ngx_http_output_filter.c +++ b/src/http/ngx_http_output_filter.c @@ -119,7 +119,7 @@ int ngx_http_output_filter(ngx_http_request_t *r, ngx_hunk_t *hunk) if (hunk->type & NGX_HUNK_IN_MEMORY) { size = hunk->last - hunk->pos; } else { - size = hunk->file_last - hunk->file_pos; + size = (size_t) (hunk->file_last - hunk->file_pos); } if (size > conf->hunk_size) { @@ -201,8 +201,8 @@ int ngx_http_output_filter(ngx_http_request_t *r, ngx_hunk_t *hunk) size = ctx->incoming->hunk->last - ctx->incoming->hunk->pos; } else { - size = ctx->incoming->hunk->file_last - - ctx->incoming->hunk->file_pos; + size = (size_t) (ctx->incoming->hunk->file_last + - ctx->incoming->hunk->file_pos); } /* delete the completed hunk from the incoming chain */ @@ -241,7 +241,7 @@ static int ngx_http_output_filter_copy_hunk(ngx_hunk_t *dst, ngx_hunk_t *src) if (src->type & NGX_HUNK_IN_MEMORY) { size = src->last - src->pos; } else { - size = src->file_last - src->file_pos; + size = (size_t) (src->file_last - src->file_pos); } if (size > (dst->end - dst->pos)) { diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c index 4d9bba99f..1b71352da 100644 --- a/src/http/ngx_http_special_response.c +++ b/src/http/ngx_http_special_response.c @@ -1,9 +1,9 @@ -#include <nginx.h> - #include <ngx_config.h> #include <ngx_core.h> -#include <ngx_string.h> + +#include <nginx.h> + #include <ngx_http.h> #include <ngx_http_output_filter.h> |
