From: Bradley Nicholes Date: Wed, 2 Jan 2002 23:10:05 +0000 (+0000) Subject: File locking updates to make mod_auth_dbm work on NetWare X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=62729e63d34d83dd66ad9a475f7f9bdc5ca1d66a;p=thirdparty%2Fapache%2Fhttpd.git File locking updates to make mod_auth_dbm work on NetWare Submitted by: Guenter Knauf git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@92710 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/lib/sdbm/sdbm.c b/src/lib/sdbm/sdbm.c index 034f712923a..f0a20f2e27a 100644 --- a/src/lib/sdbm/sdbm.c +++ b/src/lib/sdbm/sdbm.c @@ -23,6 +23,9 @@ #else #include /* for lseek() */ #endif +#ifdef NETWARE +#include +#endif /* @@ -56,6 +59,9 @@ static long masks[] = { }; datum nullitem = {NULL, 0}; +#ifdef NETWARE +extern LONG locking_sem; +#endif DBM * sdbm_open(file, flags, mode) @@ -84,6 +90,10 @@ register int mode; pagname = strcpy(dirname + strlen(dirname) + 1, file); pagname = strcat(pagname, PAGFEXT); +#ifdef NETWARE + locking_sem = OpenLocalSemaphore (1); +#endif + db = sdbm_prep(dirname, pagname, flags, mode); free((char *) dirname); return db; @@ -120,7 +130,7 @@ int mode; * open the files in sequence, and stat the dirfile. * If we fail anywhere, undo everything, return NULL. */ -#if defined(OS2) || defined(MSDOS) || defined(WIN32) +#if defined(OS2) || defined(MSDOS) || defined(WIN32) || defined(NETWARE) flags |= O_BINARY; #endif if ((db->pagf = open(pagname, flags, mode)) > -1) { @@ -166,6 +176,9 @@ register DBM *db; (void) sdbm_fd_unlock(db->pagf); (void) close(db->pagf); free((char *) db); +#ifdef NETWARE + CloseLocalSemaphore (locking_sem); +#endif } } diff --git a/src/lib/sdbm/sdbm_lock.c b/src/lib/sdbm/sdbm_lock.c index aa0f148ba71..76ac70372a6 100644 --- a/src/lib/sdbm/sdbm_lock.c +++ b/src/lib/sdbm/sdbm_lock.c @@ -21,7 +21,7 @@ #endif #if !defined(USE_FCNTL) && !defined(USE_FLOCK) #define USE_FLOCK 1 -#if !defined(MPE) && !defined(WIN32) +#if !defined(MPE) && !defined(WIN32) && !defined(NETWARE) #include #endif #ifndef LOCK_UN @@ -40,6 +40,12 @@ #define USE_LOCKING #include #endif +#ifdef NETWARE +#undef USE_FCNTL +#define USE_SEM_LOCKING +#include +LONG locking_sem = 0; +#endif #ifdef USE_FCNTL @@ -78,6 +84,12 @@ int sdbm_fd_lock(int fd, int readonly) lseek(fd, 0, SEEK_SET); rc = _locking(fd, _LK_LOCK, 1); #endif +#ifdef USE_SEM_LOCKING + if ((locking_sem != 0) && (TimedWaitOnLocalSemaphore (locking_sem, 10000) != 0)) + rc = -1; + else + rc = 1; +#endif return rc; } @@ -102,6 +114,11 @@ int sdbm_fd_unlock(int fd) lseek(fd, 0, SEEK_SET); rc = _locking(fd, _LK_UNLCK, 1); #endif +#ifdef USE_SEM_LOCKING + if (locking_sem) + SignalLocalSemaphore (locking_sem); + rc = 1; +#endif return rc; } diff --git a/src/modules/standard/mod_auth_dbm.c b/src/modules/standard/mod_auth_dbm.c index 0545e600743..75e62399aa1 100644 --- a/src/modules/standard/mod_auth_dbm.c +++ b/src/modules/standard/mod_auth_dbm.c @@ -75,7 +75,7 @@ #include "http_core.h" #include "http_log.h" #include "http_protocol.h" -#if defined(WIN32) +#if (defined(WIN32) || defined(NETWARE)) #include #define dbm_open sdbm_open #define dbm_fetch sdbm_fetch