nxt_conf_validation.c (1651:8dcd8563fe99) nxt_conf_validation.c (1681:542b5b8c0647)
1
2/*
3 * Copyright (C) Valentin V. Bartenev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8#include <nxt_conf.h>

--- 81 unchanged lines hidden (view full) ---

90static nxt_int_t nxt_conf_vldt_action(nxt_conf_validation_t *vldt,
91 nxt_conf_value_t *value, void *data);
92static nxt_int_t nxt_conf_vldt_pass(nxt_conf_validation_t *vldt,
93 nxt_conf_value_t *value, void *data);
94static nxt_int_t nxt_conf_vldt_return(nxt_conf_validation_t *vldt,
95 nxt_conf_value_t *value, void *data);
96static nxt_int_t nxt_conf_vldt_proxy(nxt_conf_validation_t *vldt,
97 nxt_conf_value_t *value, void *data);
1
2/*
3 * Copyright (C) Valentin V. Bartenev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8#include <nxt_conf.h>

--- 81 unchanged lines hidden (view full) ---

90static nxt_int_t nxt_conf_vldt_action(nxt_conf_validation_t *vldt,
91 nxt_conf_value_t *value, void *data);
92static nxt_int_t nxt_conf_vldt_pass(nxt_conf_validation_t *vldt,
93 nxt_conf_value_t *value, void *data);
94static nxt_int_t nxt_conf_vldt_return(nxt_conf_validation_t *vldt,
95 nxt_conf_value_t *value, void *data);
96static nxt_int_t nxt_conf_vldt_proxy(nxt_conf_validation_t *vldt,
97 nxt_conf_value_t *value, void *data);
98static nxt_int_t nxt_conf_vldt_threads(nxt_conf_validation_t *vldt,
99 nxt_conf_value_t *value, void *data);
100static nxt_int_t nxt_conf_vldt_thread_stack_size(nxt_conf_validation_t *vldt,
101 nxt_conf_value_t *value, void *data);
98static nxt_int_t nxt_conf_vldt_routes(nxt_conf_validation_t *vldt,
99 nxt_conf_value_t *value, void *data);
100static nxt_int_t nxt_conf_vldt_routes_member(nxt_conf_validation_t *vldt,
101 nxt_str_t *name, nxt_conf_value_t *value);
102static nxt_int_t nxt_conf_vldt_route(nxt_conf_validation_t *vldt,
103 nxt_conf_value_t *value);
104static nxt_int_t nxt_conf_vldt_match_encoded_patterns_sets(
105 nxt_conf_validation_t *vldt, nxt_conf_value_t *value, void *data);

--- 378 unchanged lines hidden (view full) ---

484 .type = NXT_CONF_VLDT_STRING,
485 }, {
486 .name = nxt_string("module"),
487 .type = NXT_CONF_VLDT_STRING,
488 .flags = NXT_CONF_VLDT_REQUIRED,
489 }, {
490 .name = nxt_string("callable"),
491 .type = NXT_CONF_VLDT_STRING,
102static nxt_int_t nxt_conf_vldt_routes(nxt_conf_validation_t *vldt,
103 nxt_conf_value_t *value, void *data);
104static nxt_int_t nxt_conf_vldt_routes_member(nxt_conf_validation_t *vldt,
105 nxt_str_t *name, nxt_conf_value_t *value);
106static nxt_int_t nxt_conf_vldt_route(nxt_conf_validation_t *vldt,
107 nxt_conf_value_t *value);
108static nxt_int_t nxt_conf_vldt_match_encoded_patterns_sets(
109 nxt_conf_validation_t *vldt, nxt_conf_value_t *value, void *data);

--- 378 unchanged lines hidden (view full) ---

488 .type = NXT_CONF_VLDT_STRING,
489 }, {
490 .name = nxt_string("module"),
491 .type = NXT_CONF_VLDT_STRING,
492 .flags = NXT_CONF_VLDT_REQUIRED,
493 }, {
494 .name = nxt_string("callable"),
495 .type = NXT_CONF_VLDT_STRING,
496 }, {
497 .name = nxt_string("threads"),
498 .type = NXT_CONF_VLDT_INTEGER,
499 .validator = nxt_conf_vldt_threads,
500 }, {
501 .name = nxt_string("thread_stack_size"),
502 .type = NXT_CONF_VLDT_INTEGER,
503 .validator = nxt_conf_vldt_thread_stack_size,
492 },
493
494 NXT_CONF_VLDT_NEXT(nxt_conf_vldt_common_members)
495};
496
497
498static nxt_conf_vldt_object_t nxt_conf_vldt_php_members[] = {
499 {

--- 824 unchanged lines hidden (view full) ---

1324 }
1325
1326 return nxt_conf_vldt_error(vldt, "The \"proxy\" address is invalid \"%V\"",
1327 &name);
1328}
1329
1330
1331static nxt_int_t
504 },
505
506 NXT_CONF_VLDT_NEXT(nxt_conf_vldt_common_members)
507};
508
509
510static nxt_conf_vldt_object_t nxt_conf_vldt_php_members[] = {
511 {

--- 824 unchanged lines hidden (view full) ---

1336 }
1337
1338 return nxt_conf_vldt_error(vldt, "The \"proxy\" address is invalid \"%V\"",
1339 &name);
1340}
1341
1342
1343static nxt_int_t
1344nxt_conf_vldt_threads(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
1345 void *data)
1346{
1347 int64_t threads;
1348
1349 threads = nxt_conf_get_number(value);
1350
1351 if (threads < 1) {
1352 return nxt_conf_vldt_error(vldt, "The \"threads\" number must be "
1353 "equal to or greater than 1.");
1354 }
1355
1356 if (threads > NXT_INT32_T_MAX) {
1357 return nxt_conf_vldt_error(vldt, "The \"threads\" number must "
1358 "not exceed %d.", NXT_INT32_T_MAX);
1359 }
1360
1361 return NXT_OK;
1362}
1363
1364
1365static nxt_int_t
1366nxt_conf_vldt_thread_stack_size(nxt_conf_validation_t *vldt,
1367 nxt_conf_value_t *value, void *data)
1368{
1369 int64_t size;
1370
1371 size = nxt_conf_get_number(value);
1372
1373 if (size < PTHREAD_STACK_MIN) {
1374 return nxt_conf_vldt_error(vldt, "The \"thread_stack_size\" number "
1375 "must be equal to or greater than %d.",
1376 PTHREAD_STACK_MIN);
1377 }
1378
1379 if ((size % nxt_pagesize) != 0) {
1380 return nxt_conf_vldt_error(vldt, "The \"thread_stack_size\" number "
1381 "must be a multiple of the system page size (%d).",
1382 nxt_pagesize);
1383 }
1384
1385 return NXT_OK;
1386}
1387
1388
1389static nxt_int_t
1332nxt_conf_vldt_routes(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
1333 void *data)
1334{
1335 if (nxt_conf_type(value) == NXT_CONF_ARRAY) {
1336 return nxt_conf_vldt_array_iterator(vldt, value,
1337 &nxt_conf_vldt_route);
1338 }
1339

--- 1057 unchanged lines hidden ---
1390nxt_conf_vldt_routes(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
1391 void *data)
1392{
1393 if (nxt_conf_type(value) == NXT_CONF_ARRAY) {
1394 return nxt_conf_vldt_array_iterator(vldt, value,
1395 &nxt_conf_vldt_route);
1396 }
1397

--- 1057 unchanged lines hidden ---