From dc6bdefe077f2a04700d00af5ae2c06634aebdb0 Mon Sep 17 00:00:00 2001 From: ngn Date: Sun, 18 Aug 2024 04:12:09 +0300 Subject: [PATCH] fix: don't reuse section names as pool names --- locale/tr/LC_MESSAGES/pooler.po | 4 ++-- src/config.c | 22 +++++++++++++++------- src/config.h | 1 + 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/locale/tr/LC_MESSAGES/pooler.po b/locale/tr/LC_MESSAGES/pooler.po index 0ee9dd2..fc9cfe3 100644 --- a/locale/tr/LC_MESSAGES/pooler.po +++ b/locale/tr/LC_MESSAGES/pooler.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-18 04:00+0300\n" +"POT-Creation-Date: 2024-08-18 04:11+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -37,7 +37,7 @@ msgstr "Kayıt dosyasını açmak başarısız oldu: %s" msgid "Failed to parse the configuration" msgstr "Kayıt dosyasını açmak başarısız oldu: %s" -#: src/config.c:157 +#: src/config.c:160 #, fuzzy, c-format msgid "Hostname not specified for the pool: %s" msgstr "Ana makine adı havuz konfigürasyonunda belirtilmedi, geçiliyor: %s" diff --git a/src/config.c b/src/config.c index 73d24d4..6cafaca 100644 --- a/src/config.c +++ b/src/config.c @@ -21,21 +21,21 @@ config_t config = { .pools = NULL, }; -pool_config_t *config_pool_add(char *name) { +pool_config_t *config_pool_add(char *section) { pool_config_t *pool = malloc(sizeof(pool_config_t)); bzero(pool, sizeof(pool_config_t)); - pool->name = strdup(name); - pool->next = config.pools; - config.pools = pool; + pool->section = strdup(section); + pool->next = config.pools; + config.pools = pool; return pool; } -bool config_pool_contains(char *name) { +bool config_pool_contains(char *section) { pool_config_t *cur = config.pools; while (NULL != cur) { - if (eq(cur->name, name)) + if (eq(cur->section, section)) return true; cur = cur->next; } @@ -153,10 +153,14 @@ bool config_load(char *file) { pool_config_t *pool = config.pools; while (NULL != pool) { + if (NULL == pool->name) + pool->name = pool->section; + if (NULL == pool->host) { error(_("Hostname not specified for the pool: %s"), pool->name); return false; } + pool = pool->next; } @@ -172,8 +176,12 @@ void config_free() { old = cur; cur = cur->next; + free(old->section); + if (old->section != old->name) + free(old->name); free(old->host); - free(old->name); + free(old->path); + free(old->dir); free(old); } } diff --git a/src/config.h b/src/config.h index 4d396a7..a06bdee 100644 --- a/src/config.h +++ b/src/config.h @@ -21,6 +21,7 @@ typedef struct config_option { typedef struct pool_config { struct pool_config *next; + char *section; char *name; char *host; char *path;