apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mladen Turk" <mladen.t...@mail.inet.hr>
Subject [PATCH] win32/locks.c - Terminal Services on WIN2K
Date Tue, 16 Oct 2001 18:13:11 GMT
Hi,

Here is the patch that deals with the strange things that took me almost a
week to solve.
I've build a service that created a lock an everything worked fine until I
run it using terminal services on WIN2K, (thanks to MSDN here is the
solution).
Don't see any reason why someone would use 'Local' namespace, (at least the
additional enum to apr_lock_create type param).

MT.


Index: locks.c
===================================================================
RCS file: /home/cvspublic/apr/locks/win32/locks.c,v
retrieving revision 1.45
diff -u -r1.45 locks.c
--- locks.c	2001/07/19 00:11:57	1.45
+++ locks.c	2001/10/16 17:41:11
@@ -58,6 +58,7 @@
 #include "apr_strings.h"
 #include "win32/locks.h"
 #include "apr_portable.h"
+#include "misc.h"

 static apr_status_t lock_cleanup(void *lock_)
 {
@@ -100,7 +101,6 @@
     /* ToDo:  How to handle the case when no pool is available?
     *         How to cleanup the storage properly?
     */
-    newlock->fname = apr_pstrdup(pool, fname);
     newlock->type = type;
     newlock->scope = scope;
     sec.nLength = sizeof(SECURITY_ATTRIBUTES);
@@ -114,9 +114,20 @@
     }

     if (scope == APR_INTRAPROCESS) {
+        newlock->fname = apr_pstrdup(pool, fname);
         InitializeCriticalSection(&newlock->section);
     } else {
-        newlock->mutex = CreateMutex(&sec, FALSE, fname);
+        apr_oslevel_e os_level;
+        if (!apr_get_oslevel(pool, &os_level) && os_level >= APR_WIN_2000)
+            newlock->fname = apr_pstrcat(pool, "Global\\", fname, NULL);
+        else
+            newlock->fname = apr_pstrdup(pool, fname);
+
+        newlock->mutex = CreateMutex(&sec, TRUE, newlock->fname);
+        if (GetLastError() == ERROR_ALREADY_EXISTS)
+            newlock->owner = 0;
+        else
+            newlock->owner = 1;
     }
     *lock = newlock;
     apr_pool_cleanup_register(newlock->pool, newlock, lock_cleanup,


Mime
View raw message