update: seperate pool dirs and libmp fixes

This commit is contained in:
ngn
2024-08-04 14:47:14 +03:00
parent 6d175d34d8
commit 6ddbb6f99a
9 changed files with 117 additions and 91 deletions

View File

@ -1,6 +1,5 @@
#include <errno.h>
#include <ini.h>
#include <libmp/all.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@ -8,6 +7,7 @@
#include "config.h"
#include "intl.h"
#include "log.h"
#include "util.h"
#define option_count() sizeof(config.options) / sizeof(config.options[0])
@ -15,9 +15,8 @@ config_t config = {
.options =
{
{.key = "threads", .type = TYPE_INTEGER, .def.integer = 10},
{.key = "tmpdir", .type = TYPE_STRING, .def.string = "/tmp/pooler"},
{.key = "addr", .type = TYPE_STRING, .def.string = "0.0.0.0:5858"},
{.key = "dir", .type = TYPE_STRING, .def.string = NULL},
{.key = "log", .type = TYPE_STRING, .def.string = NULL},
},
.pools = NULL,
};
@ -111,6 +110,11 @@ int config_load_handler(void *data, const char *_section, const char *_key, cons
config.pools->host = strdup(value);
}
else if (eq(key, "dir")) {
free(config.pools->dir);
config.pools->dir = strdup(value);
}
else
goto unknown;
@ -124,7 +128,7 @@ unknown:
bool config_load(char *file) {
config_options_clear();
if (!exists(file) || !can_read(file)) {
if (!file_canread(file)) {
error(_("Failed to access the configuration file: %s"), file);
return false;
}
@ -143,7 +147,6 @@ bool config_load(char *file) {
pool = pool->next;
}
info(_("Loaded the configuration"));
return true;
}