From 91c9e7bc373465599b220f03d17a61f814c0303b Mon Sep 17 00:00:00 2001 From: Andre Date: Tue, 21 Feb 2006 17:07:56 +0100 Subject: [PATCH] use the random dbtool as default That simplifies the code quite a bit. --- server.c | 44 ++++++++++++++------------------------------ 1 file changed, 14 insertions(+), 30 deletions(-) diff --git a/server.c b/server.c index c46966ea..538d201b 100644 --- a/server.c +++ b/server.c @@ -278,41 +278,25 @@ static void setup_signal_handling(void) static void init_dbtool(void) { - int i; + int i, ret; mmd->dbt_change = -1; /* no change nec., set to new dbt num by com_cdt */ - if (!dblist[1].name) + if (!conf.dbtool_given) goto random; - if (conf.dbtool_given) { - for (i = 0; dblist[i].name; i++) { - if (strcmp(dblist[i].name, conf.dbtool_arg)) - continue; - PARA_NOTICE_LOG("initializing %s database tool\n", - dblist[i].name); - if (dblist[i].init(&dblist[i]) < 0) { - PARA_WARNING_LOG("init %s failed", - dblist[i].name); - goto random; - } - mmd->dbt_num = i; - return; - } - PARA_WARNING_LOG("%s", "no such dbtool, switching to random\n"); - goto random; - } - /* use the first dbtool that works - * (assuming that random always works) - */ - for (i = 1; dblist[i].name; i++) { - int ret = dblist[i].init(&dblist[i]); - if (ret >= 0) { - PARA_INFO_LOG("initialized %s\n", dblist[i].name); - mmd->dbt_num = i; - return; + for (i = 0; dblist[i].name; i++) { + if (strcmp(dblist[i].name, conf.dbtool_arg)) + continue; + PARA_NOTICE_LOG("initializing %s database tool\n", + dblist[i].name); + ret = dblist[i].init(&dblist[i]); + if (ret < 0) { + PARA_WARNING_LOG("%s", PARA_STRERROR(-ret)); + break; } - PARA_CRIT_LOG("%s init failed: %s\n", dblist[i].name, - PARA_STRERROR(-ret)); + mmd->dbt_num = i; + return; } + PARA_WARNING_LOG("%s", "falling back to the random dbtool\n"); random: mmd->dbt_num = 0; dblist[0].init(&dblist[0]); /* always successful */ -- 2.39.2