]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
File locking updates to make mod_auth_dbm work on NetWare
authorBradley Nicholes <bnicholes@apache.org>
Wed, 2 Jan 2002 23:10:05 +0000 (23:10 +0000)
committerBradley Nicholes <bnicholes@apache.org>
Wed, 2 Jan 2002 23:10:05 +0000 (23:10 +0000)
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

src/lib/sdbm/sdbm.c
src/lib/sdbm/sdbm_lock.c
src/modules/standard/mod_auth_dbm.c

index 034f712923aac308911d76d3dcbc3ed1d668709b..f0a20f2e27ad294a9d44d097e52ca84314971812 100644 (file)
@@ -23,6 +23,9 @@
 #else
 #include <unistd.h>    /* for lseek() */
 #endif
+#ifdef NETWARE
+#include <nwsemaph.h>
+#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
        }
 }
 
index aa0f148ba71115679e5c6837de24d1656f75c407..76ac70372a6cb4e65ef0fb55239e4fa075044e6c 100644 (file)
@@ -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 <sys/file.h>
 #endif
 #ifndef LOCK_UN
 #define USE_LOCKING
 #include <sys/locking.h>
 #endif
+#ifdef NETWARE
+#undef USE_FCNTL
+#define USE_SEM_LOCKING
+#include <nwsemaph.h>
+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;
 }
index 0545e600743b717aa5aad9f0c41bd1bde6719ecb..75e62399aa11b9fc04f37aa9055d103bb9d3815e 100644 (file)
@@ -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 <sdbm.h>
 #define dbm_open sdbm_open
 #define dbm_fetch sdbm_fetch