refuse to start on any configuration error that is not fatal for processing the configuration file
Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
parent
6b47d522da
commit
28c33bf99a
1 changed files with 8 additions and 2 deletions
|
@ -85,7 +85,8 @@ struct cfgst_node {
|
||||||
struct cfgst {
|
struct cfgst {
|
||||||
ut_avlTree_t found;
|
ut_avlTree_t found;
|
||||||
struct config *cfg;
|
struct config *cfg;
|
||||||
|
/* error flag set so that we can continue parsing for some errors and still fail properly */
|
||||||
|
int error;
|
||||||
|
|
||||||
/* path_depth, isattr and path together control the formatting of
|
/* path_depth, isattr and path together control the formatting of
|
||||||
error messages by cfg_error() */
|
error messages by cfg_error() */
|
||||||
|
@ -1031,6 +1032,10 @@ static size_t cfg_note(struct cfgst *cfgst, logcat_t cat, size_t bsz, const char
|
||||||
int i, sidx;
|
int i, sidx;
|
||||||
size_t r;
|
size_t r;
|
||||||
|
|
||||||
|
if (cat & LC_ERROR) {
|
||||||
|
cfgst->error = 1;
|
||||||
|
}
|
||||||
|
|
||||||
bb.bufpos = 0;
|
bb.bufpos = 0;
|
||||||
bb.bufsize = (bsz == 0) ? 1024 : bsz;
|
bb.bufsize = (bsz == 0) ? 1024 : bsz;
|
||||||
if ( (bb.buf = os_malloc(bb.bufsize)) == NULL )
|
if ( (bb.buf = os_malloc(bb.bufsize)) == NULL )
|
||||||
|
@ -2681,6 +2686,7 @@ struct cfgst * config_init
|
||||||
|
|
||||||
ut_avlInit(&cfgst_found_treedef, &cfgst->found);
|
ut_avlInit(&cfgst_found_treedef, &cfgst->found);
|
||||||
cfgst->cfg = &config;
|
cfgst->cfg = &config;
|
||||||
|
cfgst->error = 0;
|
||||||
|
|
||||||
/* configfile == NULL will get you the default configuration */
|
/* configfile == NULL will get you the default configuration */
|
||||||
if ( configfile ) {
|
if ( configfile ) {
|
||||||
|
@ -2713,7 +2719,7 @@ struct cfgst * config_init
|
||||||
}
|
}
|
||||||
cfgst_push(cfgst, 0, &root_cfgelem, &config);
|
cfgst_push(cfgst, 0, &root_cfgelem, &config);
|
||||||
|
|
||||||
ok = (ut_xmlpParse(qx) >= 0);
|
ok = (ut_xmlpParse(qx) >= 0) && !cfgst->error;
|
||||||
/* Pop until stack empty: error handling is rather brutal */
|
/* Pop until stack empty: error handling is rather brutal */
|
||||||
assert(!ok || cfgst->path_depth == 1);
|
assert(!ok || cfgst->path_depth == 1);
|
||||||
while ( cfgst->path_depth > 0 )
|
while ( cfgst->path_depth > 0 )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue