diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/nginx.h | 2 | ||||
-rw-r--r-- | src/core/ngx_conf_file.c | 31 | ||||
-rw-r--r-- | src/core/ngx_conf_file.h | 12 | ||||
-rw-r--r-- | src/core/ngx_inet.c | 10 | ||||
-rw-r--r-- | src/core/ngx_inet.h | 2 | ||||
-rw-r--r-- | src/core/ngx_parse.c | 45 | ||||
-rw-r--r-- | src/core/ngx_parse.h | 1 |
7 files changed, 96 insertions, 7 deletions
diff --git a/src/core/nginx.h b/src/core/nginx.h index ad8c76838..50746ae1e 100644 --- a/src/core/nginx.h +++ b/src/core/nginx.h @@ -8,7 +8,7 @@ #define _NGINX_H_INCLUDED_ -#define NGINX_VER "nginx/0.3.52" +#define NGINX_VER "nginx/0.3.53" #define NGINX_VAR "NGINX" #define NGX_OLDPID_EXT ".oldbin" diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c index 94dfe6276..b5d8b1626 100644 --- a/src/core/ngx_conf_file.c +++ b/src/core/ngx_conf_file.c @@ -1036,6 +1036,37 @@ ngx_conf_set_size_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) char * +ngx_conf_set_off_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) +{ + char *p = conf; + + off_t *op; + ngx_str_t *value; + ngx_conf_post_t *post; + + + op = (off_t *) (p + cmd->offset); + if (*op != NGX_CONF_UNSET) { + return "is duplicate"; + } + + value = cf->args->elts; + + *op = ngx_parse_offset(&value[1]); + if (*op == (off_t) NGX_ERROR) { + return "invalid value"; + } + + if (cmd->post) { + post = cmd->post; + return post->post_handler(cf, post, op); + } + + return NGX_CONF_OK; +} + + +char * ngx_conf_set_msec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { char *p = conf; diff --git a/src/core/ngx_conf_file.h b/src/core/ngx_conf_file.h index 17c24c725..7d5112919 100644 --- a/src/core/ngx_conf_file.h +++ b/src/core/ngx_conf_file.h @@ -236,8 +236,8 @@ char *ngx_conf_check_num_bounds(ngx_conf_t *cf, void *post, void *data); conf = default; \ } -#define ngx_conf_init_unsigned_value(conf, default) \ - if (conf == (unsigned) NGX_CONF_UNSET) { \ +#define ngx_conf_init_uint_value(conf, default) \ + if (conf == NGX_CONF_UNSET_UINT) { \ conf = default; \ } @@ -261,7 +261,7 @@ char *ngx_conf_check_num_bounds(ngx_conf_t *cf, void *post, void *data); conf = (prev == NULL) ? default : prev; \ } -#define ngx_conf_merge_unsigned_value(conf, prev, default) \ +#define ngx_conf_merge_uint_value(conf, prev, default) \ if (conf == NGX_CONF_UNSET_UINT) { \ conf = (prev == NGX_CONF_UNSET_UINT) ? default : prev; \ } @@ -281,6 +281,11 @@ char *ngx_conf_check_num_bounds(ngx_conf_t *cf, void *post, void *data); conf = (prev == NGX_CONF_UNSET_SIZE) ? default : prev; \ } +#define ngx_conf_merge_off_value(conf, prev, default) \ + if (conf == NGX_CONF_UNSET) { \ + conf = (prev == NGX_CONF_UNSET) ? default : prev; \ + } + #define ngx_conf_merge_str_value(conf, prev, default) \ if (conf.data == NULL) { \ if (prev.data) { \ @@ -328,6 +333,7 @@ char *ngx_conf_set_str_array_slot(ngx_conf_t *cf, ngx_command_t *cmd, char *ngx_conf_set_keyval_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); char *ngx_conf_set_num_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); char *ngx_conf_set_size_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); +char *ngx_conf_set_off_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); char *ngx_conf_set_msec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); char *ngx_conf_set_sec_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); char *ngx_conf_set_bufs_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); diff --git a/src/core/ngx_inet.c b/src/core/ngx_inet.c index f2b0cf78b..7b3fef304 100644 --- a/src/core/ngx_inet.c +++ b/src/core/ngx_inet.c @@ -479,7 +479,6 @@ ngx_inet_resolve_peer(ngx_conf_t *cf, ngx_str_t *name, in_port_t port) } peers->number = i; - peers->weight = 1; for (i = 0; h->h_addr_list[i] != NULL; i++) { @@ -511,6 +510,10 @@ ngx_inet_resolve_peer(ngx_conf_t *cf, ngx_str_t *name, in_port_t port) - peers->peer[i].name.data; peers->peer[i].uri_separator = ""; + + peers->peer[i].weight = NGX_CONF_UNSET_UINT; + peers->peer[i].max_fails = NGX_CONF_UNSET_UINT; + peers->peer[i].fail_timeout = NGX_CONF_UNSET; } } else { @@ -643,7 +646,6 @@ ngx_inet_upstream_parse(ngx_conf_t *cf, ngx_inet_upstream_t *u) } peers->number = i; - peers->weight = 1; for (i = 0; h->h_addr_list[i] != NULL; i++) { @@ -677,6 +679,10 @@ ngx_inet_upstream_parse(ngx_conf_t *cf, ngx_inet_upstream_t *u) peers->peer[i].name.len = len + u->port_text.len; peers->peer[i].uri_separator = ""; + + peers->peer[i].weight = NGX_CONF_UNSET_UINT; + peers->peer[i].max_fails = NGX_CONF_UNSET_UINT; + peers->peer[i].fail_timeout = NGX_CONF_UNSET; } } else { diff --git a/src/core/ngx_inet.h b/src/core/ngx_inet.h index 7600ed801..301402382 100644 --- a/src/core/ngx_inet.h +++ b/src/core/ngx_inet.h @@ -29,6 +29,7 @@ typedef struct { ngx_str_t name; char *uri_separator; + ngx_uint_t current_weight; ngx_uint_t weight; ngx_uint_t fails; @@ -45,7 +46,6 @@ typedef struct { struct ngx_peers_s { ngx_uint_t current; - ngx_uint_t weight; ngx_uint_t number; ngx_uint_t last_cached; diff --git a/src/core/ngx_parse.c b/src/core/ngx_parse.c index 28e5d96c1..786824562 100644 --- a/src/core/ngx_parse.c +++ b/src/core/ngx_parse.c @@ -47,6 +47,51 @@ ngx_parse_size(ngx_str_t *line) } +off_t +ngx_parse_offset(ngx_str_t *line) +{ + u_char last; + off_t offset; + size_t len; + ngx_int_t scale; + + len = line->len; + last = line->data[len - 1]; + + switch (last) { + case 'K': + case 'k': + len--; + scale = 1024; + break; + + case 'M': + case 'm': + len--; + scale = 1024 * 1024; + break; + + case 'G': + case 'g': + len--; + scale = 1024 * 1024 * 1024; + break; + + default: + scale = 1; + } + + offset = ngx_atoof(line->data, len); + if (offset == NGX_ERROR) { + return NGX_ERROR; + } + + offset *= scale; + + return offset; +} + + ngx_int_t ngx_parse_time(ngx_str_t *line, ngx_int_t sec) { diff --git a/src/core/ngx_parse.h b/src/core/ngx_parse.h index 464cefcb8..cf3f0b2be 100644 --- a/src/core/ngx_parse.h +++ b/src/core/ngx_parse.h @@ -16,6 +16,7 @@ ssize_t ngx_parse_size(ngx_str_t *line); +off_t ngx_parse_offset(ngx_str_t *line); ngx_int_t ngx_parse_time(ngx_str_t *line, ngx_int_t sec); |