]> arthur.barton.de Git - netatalk.git/blobdiff - etc/cnid_dbd/cnid_metad.c
Improve reliability of afpd child handler
[netatalk.git] / etc / cnid_dbd / cnid_metad.c
index 18e063da638180339b4c5f9dec0fd75b8cf7a926..1b991cb8bf39d5f89a86d4f3c849e3d63b4379ce 100644 (file)
@@ -87,7 +87,7 @@
 
 #include <atalk/util.h>
 #include <atalk/logger.h>
-#include <atalk/cnid_dbd_private.h>
+#include <atalk/cnid_bdb_private.h>
 #include <atalk/paths.h>
 #include <atalk/compat.h>
 #include <atalk/errchk.h>
@@ -184,8 +184,8 @@ static int maybe_start_dbd(const AFPObj *obj, char *dbdpn, const char *volpath)
     time(&t);
     if (!up) {
         /* find an empty slot (i < maxvol) or the first free slot (i == maxvol)*/
-        for (i = 0; i <= maxvol; i++) {
-            if (srv[i].v_path == NULL && i < MAXVOLS) {
+        for (i = 0; i <= maxvol && i < MAXVOLS; i++) {
+            if (srv[i].v_path == NULL) {
                 up = &srv[i];
                 if ((up->v_path = strdup(volpath)) == NULL)
                     return -1;
@@ -463,12 +463,12 @@ int main(int argc, char *argv[])
     if (afp_config_parse(&obj, "cnid_metad") != 0)
         daemon_exit(1);
 
-    if (load_volumes(&obj) != 0)
+    if (load_volumes(&obj, lv_all) != 0)
         daemon_exit(1);
 
     (void)setlimits();
 
-    host = iniparser_getstrdup(obj.iniconfig, INISEC_GLOBAL, "cnid listen", "localhost:4700");
+    host = atalk_iniparser_getstrdup(obj.iniconfig, INISEC_GLOBAL, "cnid listen", "localhost:4700");
     if ((port = strrchr(host, ':')))
         *port++ = 0;
     else
@@ -565,7 +565,7 @@ int main(int argc, char *argv[])
 
         LOG(log_debug, logtype_cnid, "main: request for volume: %s", volpath);
 
-        if (load_volumes(&obj) != 0) {
+        if (load_volumes(&obj, lv_all) != 0) {
             LOG(log_severe, logtype_cnid, "main: error reloading config");
             goto loop_end;
         }