]> arthur.barton.de Git - netatalk.git/commitdiff
Locking was still not right, oh my
authorFrank Lahm <franklahm@googlemail.com>
Sat, 16 Apr 2011 14:12:46 +0000 (16:12 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Sat, 16 Apr 2011 14:12:46 +0000 (16:12 +0200)
etc/cnid_dbd/cmd_dbd.c

index f915b9961f973bd0a1af4b42af4dcdda473260d6..969577a5887536c9c9d422903d6453ac861d416d 100644 (file)
@@ -407,9 +407,14 @@ int main(int argc, char **argv)
         close(dbdirfd);
     }
 
+    /* 
+       Before we do anything else, check if there is an instance of cnid_dbd
+       running already and silently exit if yes.
+    */
+    lockfd = get_lock(dbpath);
+
     /* Prepare upgrade ? */
     if (prep_upgrade) {
-        lockfd = get_lock(dbpath);
         if (dbif_prep_upgrade(dbpath))
             goto exit_failure;
         goto exit_success;
@@ -418,18 +423,14 @@ int main(int argc, char **argv)
     /* Check if -f is requested and wipe db if yes */
     if ((flags & DBD_FLAGS_FORCE) && rebuild && (volinfo.v_flags & AFPVOL_CACHE)) {
         char cmd[8 + MAXPATHLEN];
+        close(lockfd);
         snprintf(cmd, 8 + MAXPATHLEN, "rm -f %s/*", dbpath);
         dbd_log( LOGDEBUG, "Removing old database of volume: '%s'", volpath);
         system(cmd);
         dbd_log( LOGDEBUG, "Removed old database.");
+        lockfd = get_lock(dbpath);
     }
 
-    /* 
-       Before we do anything else, check if there is an instance of cnid_dbd
-       running already and silently exit if yes.
-    */
-    lockfd = get_lock(dbpath);
-
     /* 
        Lets start with the BerkeleyDB stuff
     */