You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/04/27 20:23:35 UTC

svn commit: r769086 - in /commons/sandbox/runtime/trunk/src/main/native/os/win32: file.c main.c

Author: mturk
Date: Mon Apr 27 18:23:35 2009
New Revision: 769086

URL: http://svn.apache.org/viewvc?rev=769086&view=rev
Log:
Do not use APR's atexit. We have DllMain

Modified:
    commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c?rev=769086&r1=769085&r2=769086&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c Mon Apr 27 18:23:35 2009
@@ -248,20 +248,7 @@
     return rv;
 }
 
-static int free_localheap(void *heap) {
-    LocalFree(heap);
-    return 0;
-}
-
-static PSID worldid = NULL;
-
-static void free_world(void)
-{
-    if (worldid) {
-        FreeSid(worldid);
-        worldid = NULL;
-    }
-}
+extern PSID dll_worldid;
 
 /* Left bit shifts from World scope to given scope */
 typedef enum prot_scope_e {
@@ -295,13 +282,11 @@
      * This function is only invoked for WinNT,
      * there is no reason for os_level testing here.
      */
-    if (!worldid) {
+    if (!dll_worldid) {
         SID_IDENTIFIER_AUTHORITY SIDAuth = SECURITY_WORLD_SID_AUTHORITY;
-        if (AllocateAndInitializeSid(&SIDAuth, 1, SECURITY_WORLD_RID,
-                                     0, 0, 0, 0, 0, 0, 0, &worldid))
-            atexit(free_world);
-        else
-            worldid = NULL;
+        if (!AllocateAndInitializeSid(&SIDAuth, 1, SECURITY_WORLD_RID,
+                                      0, 0, 0, 0, 0, 0, 0, &dll_worldid))
+            dll_worldid = NULL;
     }
     if (user) {
         ident.TrusteeType = TRUSTEE_IS_USER;
@@ -326,9 +311,9 @@
             protection |= convert_prot(acc, prot_scope_group);
         }
     }
-    if (worldid) {
+    if (dll_worldid) {
         ident.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP;
-        ident.ptstrName = worldid;
+        ident.ptstrName = dll_worldid;
         if (GetEffectiveRightsFromAclW(dacl, &ident, &acc) == ERROR_SUCCESS) {
             protection |= convert_prot(acc, prot_scope_world);
         }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c?rev=769086&r1=769085&r2=769086&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c Mon Apr 27 18:23:35 2009
@@ -43,6 +43,8 @@
 extern int ACR_InitClazzCache(JNIEnv *);
 extern int ACR_DestroyClazzCache(JNIEnv *);
 
+PSID dll_worldid = NULL;
+
 typedef struct acr_thread_local_t {
     JNIEnv  *env;
     int     attached;
@@ -81,6 +83,10 @@
          *  or FreeLibrary.
          */
         case DLL_PROCESS_DETACH:
+            if (dll_worldid) {
+                FreeSid(dll_worldid);
+                dll_worldid = NULL;
+            }
             if (dll_tls_index != TLS_OUT_OF_INDEXES) {
                 tlsd = (acr_thread_local_t *)TlsGetValue(dll_tls_index);
                 if (tlsd) {