diff options
-rw-r--r-- | src/nxt_conf.c | 23 | ||||
-rw-r--r-- | src/nxt_conf.h | 2 | ||||
-rw-r--r-- | src/nxt_router.c | 28 |
3 files changed, 18 insertions, 35 deletions
diff --git a/src/nxt_conf.c b/src/nxt_conf.c index 935afab9..2dc4a69c 100644 --- a/src/nxt_conf.c +++ b/src/nxt_conf.c @@ -349,7 +349,8 @@ nxt_conf_get_object_member(nxt_conf_value_t *value, nxt_str_t *name, nxt_int_t -nxt_conf_map_object(nxt_conf_value_t *value, nxt_conf_map_t *map, void *data) +nxt_conf_map_object(nxt_conf_value_t *value, nxt_conf_map_t *map, nxt_uint_t n, + void *data) { nxt_uint_t i; nxt_conf_value_t *v; @@ -367,7 +368,7 @@ nxt_conf_map_object(nxt_conf_value_t *value, nxt_conf_map_t *map, void *data) void *v; } *ptr; - for (i = 0; map[i].name.length != 0; i++) { + for (i = 0; i < n; i++) { v = nxt_conf_get_object_member(value, &map[i].name, NULL); @@ -381,12 +382,10 @@ nxt_conf_map_object(nxt_conf_value_t *value, nxt_conf_map_t *map, void *data) case NXT_CONF_MAP_INT8: - if (v->type != NXT_CONF_VALUE_BOOLEAN) { - return NXT_ERROR; + if (v->type == NXT_CONF_VALUE_BOOLEAN) { + ptr->ui8 = v->u.boolean; } - ptr->ui8 = v->u.boolean; - break; case NXT_CONF_MAP_INT32: @@ -397,7 +396,7 @@ nxt_conf_map_object(nxt_conf_value_t *value, nxt_conf_map_t *map, void *data) case NXT_CONF_MAP_MSEC: if (v->type != NXT_CONF_VALUE_INTEGER) { - return NXT_ERROR; + break; } switch (map[i].type) { @@ -440,22 +439,18 @@ nxt_conf_map_object(nxt_conf_value_t *value, nxt_conf_map_t *map, void *data) } else if (v->type == NXT_CONF_VALUE_INTEGER) { ptr->dbl = v->u.integer; - } else { - return NXT_ERROR; } break; case NXT_CONF_MAP_STR: - if (v->type != NXT_CONF_VALUE_SHORT_STRING - && v->type != NXT_CONF_VALUE_STRING) + if (v->type == NXT_CONF_VALUE_SHORT_STRING + || v->type == NXT_CONF_VALUE_STRING) { - return NXT_ERROR; + nxt_conf_get_string(v, &ptr->str); } - nxt_conf_get_string(v, &ptr->str); - break; diff --git a/src/nxt_conf.h b/src/nxt_conf.h index d9021732..90a4450a 100644 --- a/src/nxt_conf.h +++ b/src/nxt_conf.h @@ -58,7 +58,7 @@ nxt_conf_value_t *nxt_conf_next_object_member(nxt_conf_value_t *value, nxt_str_t *name, uint32_t *next); nxt_int_t nxt_conf_map_object(nxt_conf_value_t *value, nxt_conf_map_t *map, - void *data); + nxt_uint_t n, void *data); nxt_int_t nxt_conf_op_compile(nxt_mp_t *mp, nxt_conf_op_t **ops, nxt_conf_value_t *root, nxt_str_t *path, nxt_conf_value_t *value); diff --git a/src/nxt_router.c b/src/nxt_router.c index 2089a704..be47e453 100644 --- a/src/nxt_router.c +++ b/src/nxt_router.c @@ -235,10 +235,6 @@ static nxt_conf_map_t nxt_router_conf[] = { NXT_CONF_MAP_INT32, offsetof(nxt_router_conf_t, threads), }, - - { - nxt_null_string, 0, 0, - }, }; @@ -254,10 +250,6 @@ static nxt_conf_map_t nxt_router_app_conf[] = { NXT_CONF_MAP_INT32, offsetof(nxt_router_app_conf_t, workers), }, - - { - nxt_null_string, 0, 0, - }, }; @@ -267,10 +259,6 @@ static nxt_conf_map_t nxt_router_listener_conf[] = { NXT_CONF_MAP_STR, offsetof(nxt_router_listener_conf_t, application), }, - - { - nxt_null_string, 0, 0, - }, }; @@ -292,10 +280,6 @@ static nxt_conf_map_t nxt_router_http_conf[] = { NXT_CONF_MAP_MSEC, offsetof(nxt_socket_conf_t, header_read_timeout), }, - - { - nxt_null_string, 0, 0, - }, }; @@ -330,7 +314,8 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf, return NXT_ERROR; } - ret = nxt_conf_map_object(conf, nxt_router_conf, tmcf->conf); + ret = nxt_conf_map_object(conf, nxt_router_conf, + nxt_nitems(nxt_router_conf), tmcf->conf); if (ret != NXT_OK) { nxt_log(task, NXT_LOG_CRIT, "root map error"); return NXT_ERROR; @@ -385,7 +370,8 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf, continue; } - ret = nxt_conf_map_object(application, nxt_router_app_conf, &apcf); + ret = nxt_conf_map_object(application, nxt_router_app_conf, + nxt_nitems(nxt_router_app_conf), &apcf); if (ret != NXT_OK) { nxt_log(task, NXT_LOG_CRIT, "application map error"); goto app_fail; @@ -465,7 +451,8 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf, goto fail; } - ret = nxt_conf_map_object(listener, nxt_router_listener_conf, &lscf); + ret = nxt_conf_map_object(listener, nxt_router_listener_conf, + nxt_nitems(nxt_router_listener_conf), &lscf); if (ret != NXT_OK) { nxt_log(task, NXT_LOG_CRIT, "listener map error"); goto fail; @@ -479,7 +466,8 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf, skcf->header_read_timeout = 5000; if (http != NULL) { - ret = nxt_conf_map_object(http, nxt_router_http_conf, skcf); + ret = nxt_conf_map_object(http, nxt_router_http_conf, + nxt_nitems(nxt_router_http_conf), skcf); if (ret != NXT_OK) { nxt_log(task, NXT_LOG_CRIT, "http map error"); goto fail; |