From: jmarcus Date: Sun, 4 Nov 2001 22:13:50 +0000 (+0000) Subject: Add a static variable to track the exclusive lock. Seems Macs like to open X-Git-Tag: netatalk-1-5-rc1~67 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=commitdiff_plain;h=f5297b2df3905212f4c87d5100fd88247f40d4d1 Add a static variable to track the exclusive lock. Seems Macs like to open the database numerous time per thread of control. This will keep the DB_RECOVER flag from being used more than it should. --- diff --git a/libatalk/cnid/cnid_open.c b/libatalk/cnid/cnid_open.c index 2207a55a..2204b4aa 100644 --- a/libatalk/cnid/cnid_open.c +++ b/libatalk/cnid/cnid_open.c @@ -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; }