From 435e7c62382df0adcfcec0bae6fd8e65c7dacbda Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Sun, 3 Jan 2016 20:31:46 +0100 Subject: conf: keep the struct conf allocated --- src/conf.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'src/conf.c') diff --git a/src/conf.c b/src/conf.c index 4f08d70..bc29ba7 100644 --- a/src/conf.c +++ b/src/conf.c @@ -315,6 +315,7 @@ int conf_configure(void) goto out; } + conf_obj = mem_deref(conf_obj); err = conf_alloc(&conf_obj, file); if (err) goto out; @@ -324,7 +325,6 @@ int conf_configure(void) goto out; out: - conf_obj = mem_deref(conf_obj); return err; } @@ -333,23 +333,13 @@ int conf_configure(void) * Load all modules from config file * * @return 0 if success, otherwise errorcode + * + * @note conf_configure must be called first */ int conf_modules(void) { - char path[256], file[256]; int err; - err = conf_path_get(path, sizeof(path)); - if (err) - return err; - - if (re_snprintf(file, sizeof(file), "%s/config", path) < 0) - return ENOMEM; - - err = conf_alloc(&conf_obj, file); - if (err) - goto out; - err = module_init(conf_obj); if (err) { warning("conf: configure module parse error (%m)\n", err); @@ -364,7 +354,6 @@ int conf_modules(void) #endif out: - conf_obj = mem_deref(conf_obj); return err; } @@ -378,5 +367,15 @@ int conf_modules(void) */ struct conf *conf_cur(void) { + if (!conf_obj) { + warning("conf: no config object\n"); + } return conf_obj; } + + +void conf_close(void) +{ + mod_close(); + conf_obj = mem_deref(conf_obj); +} -- cgit v1.2.3