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/09/21 16:42:14 UTC

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

Author: mturk
Date: Mon Sep 21 14:42:14 2009
New Revision: 817272

URL: http://svn.apache.org/viewvc?rev=817272&view=rev
Log:
Don't continue init until main thread initialized

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

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=817272&r1=817271&r2=817272&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 Sep 21 14:42:14 2009
@@ -119,13 +119,16 @@
                 /* No point to continue if we cannot have TLSD */
                 return FALSE;
             }
+            TlsSetValue(dll_tls_index, NULL);
         break;
         /** The attached process creates a new thread.
          */
         case DLL_THREAD_ATTACH:
             /* Make sure we have initialized the slot.
              */
-            TlsSetValue(dll_tls_index, NULL);
+            if (dll_tls_index != TLS_OUT_OF_INDEXES) {
+                TlsSetValue(dll_tls_index, NULL);
+            }
         break;
         /** The thread of the attached process terminates.
          */
@@ -134,6 +137,7 @@
                 tlsd = (acr_thread_local_t *)TlsGetValue(dll_tls_index);
                 if (tlsd) {
                     acr_thread_key_destructor(tlsd);
+                    TlsSetValue(dll_tls_index, NULL);
                 }
             }
         break;
@@ -148,6 +152,7 @@
                 }
                 TlsFree(dll_tls_index);
             }
+            dll_tls_index = TLS_OUT_OF_INDEXES;
             acr_dll_exit();
             dll_instance = NULL;
         break;
@@ -409,6 +414,7 @@
         }
         else {
             tlsd->id = (unsigned int)InterlockedIncrement(&acr_thread_id_cur);
+            ACR_RING_INIT(&tlsd->data_ring, acr_tlsd_data_t, link);                
             TlsSetValue(dll_tls_index, tlsd);
             return tlsd;
         }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c?rev=817272&r1=817271&r2=817272&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c Mon Sep 21 14:42:14 2009
@@ -473,6 +473,10 @@
         sync.hEvent = wh[nw++];
         cs = sig_pipe_connect(&sync);
     }
+    do {
+        SetEvent(sig_handle_event);
+        Sleep(1);
+    } while (IS_INVALID_HANDLE(sig_handle_thread));
 
     while (running) {
         rc = WaitForMultipleObjectsEx(nw, wh, FALSE, INFINITE, TRUE);
@@ -641,6 +645,7 @@
          */
          goto cleanup;
     }
+    WaitForSingleObject(sig_handle_event, INFINITE);
     sig_handle_thread = h;
     if (!SetConsoleCtrlHandler(console_event_handler, TRUE)) {
         int rc = ACR_GET_OS_ERROR();