summaryrefslogtreecommitdiff
path: root/src/conf.c
diff options
context:
space:
mode:
authorAlfred E. Heggestad <aeh@db.org>2016-01-03 20:31:46 +0100
committerAlfred E. Heggestad <aeh@db.org>2016-01-03 20:31:46 +0100
commit435e7c62382df0adcfcec0bae6fd8e65c7dacbda (patch)
tree002c518e7c33f2f2f1cf6d986e5bc169f3901a13 /src/conf.c
parent837aa4dd496ccec4dc6174aad3e5021dfdc6fffe (diff)
conf: keep the struct conf allocated
Diffstat (limited to 'src/conf.c')
-rw-r--r--src/conf.c27
1 files changed, 13 insertions, 14 deletions
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);
+}