]> arthur.barton.de Git - netatalk.git/commitdiff
Don't remove BerkeleyDB if it's still in use by eg cnid_dbd
authorFrank Lahm <franklahm@googlemail.com>
Fri, 30 Mar 2012 08:43:42 +0000 (10:43 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Fri, 30 Mar 2012 08:43:42 +0000 (10:43 +0200)
NEWS
etc/cnid_dbd/dbif.c
etc/cnid_dbd/pack.h

diff --git a/NEWS b/NEWS
index e47a168017cf0daf0d0698e92e192fd3b321125b..fc458acf8f4d31f526571f83b293fb451b21df10 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,8 @@ Changes in 2.2.3
 * FIX: afpd: Dont use searchdb when doing partial name search
 * FIX: afpd: Fix a possible bug handling disconnected sessions,
        NetAFP Bug ID #16
 * FIX: afpd: Dont use searchdb when doing partial name search
 * FIX: afpd: Fix a possible bug handling disconnected sessions,
        NetAFP Bug ID #16
+* FIX: dbd: Don't remove BerkeleyDB if it's still in use by eg cnid_dbd, fixes
+       bug introduced in 2.2.2
 * FIX: debian initscript: start avahi-daemon (if available) before atalkd
 
 Changes in 2.2.2
 * FIX: debian initscript: start avahi-daemon (if available) before atalkd
 
 Changes in 2.2.2
index b96b2e6878c38f0f807a10387d12a69b487faa34..fc251a7698241292815c29c85b78bbf3019f103a 100644 (file)
@@ -805,7 +805,12 @@ int dbif_env_remove(const char *path)
     int ret;
     DBD *dbd;
 
     int ret;
     DBD *dbd;
 
-    LOG(log_debug, logtype_cnid, "Reopening BerkeleyDB environment");
+    LOG(log_debug, logtype_cnid, "Trying to remove BerkeleyDB environment");
+
+    if (get_lock(LOCK_EXCL, path) != LOCK_EXCL) {
+        LOG(log_warning, logtype_cnid, "CNID db \"%s\" in use, can't remove BerkeleyDB environment", path);
+        return 0;
+    }
     
     if (NULL == (dbd = dbif_init(path, "cnid2.db")))
         return -1;
     
     if (NULL == (dbd = dbif_init(path, "cnid2.db")))
         return -1;
index e94ef0d9a11a827faf2aa3b3e4145ce52df0b52b..fc3d65b1575b584c180e0fe06cb3da3955f87c49 100644 (file)
 #include <db.h>
 #include <atalk/cnid_dbd_private.h>
 
 #include <db.h>
 #include <atalk/cnid_dbd_private.h>
 
-#define ntoh64(x)       (((uint64_t)(x) << 56) | \
-                        (((uint64_t)(x) << 40) & 0xff000000000000ULL) | \
-                        (((uint64_t)(x) << 24) & 0xff0000000000ULL) | \
-                        (((uint64_t)(x) << 8)  & 0xff00000000ULL) | \
-                        (((uint64_t)(x) >> 8)  & 0xff000000ULL) | \
-                        (((uint64_t)(x) >> 24) & 0xff0000ULL) | \
-                        (((uint64_t)(x) >> 40) & 0xff00ULL) | \
-                        ((uint64_t)(x)  >> 56))
-
 extern unsigned char *pack_cnid_data(struct cnid_dbd_rqst *);
 extern int didname(DB *dbp, const DBT *pkey, const DBT *pdata, DBT *skey);
 extern int devino(DB *dbp, const DBT *pkey, const DBT *pdata, DBT *skey);
 extern unsigned char *pack_cnid_data(struct cnid_dbd_rqst *);
 extern int didname(DB *dbp, const DBT *pkey, const DBT *pdata, DBT *skey);
 extern int devino(DB *dbp, const DBT *pkey, const DBT *pdata, DBT *skey);