]> arthur.barton.de Git - netatalk.git/commitdiff
Add a static variable to track the exclusive lock. Seems Macs like to open
authorjmarcus <jmarcus>
Sun, 4 Nov 2001 22:13:50 +0000 (22:13 +0000)
committerjmarcus <jmarcus>
Sun, 4 Nov 2001 22:13:50 +0000 (22:13 +0000)
the database numerous time per thread of control.  This will keep the
DB_RECOVER flag from being used more than it should.

libatalk/cnid/cnid_open.c

index 2207a55a28e6fdd7cdafb805fc3c0dd9a4f595eb..2204b4aae08271968711481d83b382a245d2a40d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: cnid_open.c,v 1.17 2001-11-04 17:34:15 jmarcus Exp $
+ * $Id: cnid_open.c,v 1.18 2001-11-04 22:13:50 jmarcus Exp $
  *
  * Copyright (c) 1999. Adrian Sun (asun@zoology.washington.edu)
  * All Rights Reserved. See COPYRIGHT.
@@ -171,6 +171,8 @@ static int compare_unicode(const DBT *a, const DBT *b)
 #endif /* DB_VERSION_MINOR */
 }
 
+static int have_lock = 0;
+
 void *cnid_open(const char *dir) {
        struct stat st;
        struct flock lock;
@@ -236,7 +238,7 @@ void *cnid_open(const char *dir) {
                syslog(LOG_INFO, "cnid_open: Cannot establish logfile cleanup lock (open() failed)");
        }
        
-       if (db->lockfd > -1 && lock.l_start == 0) {
+       if (!have_lock && db->lockfd > -1 && lock.l_start == 0) {
                /* We test to see if we have exclusive database access.  If we do, we
                 * will open the database with the DB_RECOVER flag.
                 */
@@ -244,6 +246,7 @@ void *cnid_open(const char *dir) {
                syslog(LOG_INFO, "cnid_open: Opening database with DB_RECOVER flag");
 #endif
                DBEXTRAS |= DB_RECOVER;
+               have_lock = 1;
        }