use the random dbtool as default
authorAndre <maan@p133.(none)>
Tue, 21 Feb 2006 16:07:56 +0000 (17:07 +0100)
committerAndre <maan@p133.(none)>
Tue, 21 Feb 2006 16:07:56 +0000 (17:07 +0100)
That simplifies the code quite a bit.

server.c

index c46966e..538d201 100644 (file)
--- 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 */