]> git.pond.sub.org Git - empserver/blobdiff - src/lib/empthread/ntthread.c
(empth_init_signals): Don't catch SIGINT and SIGTERM.
[empserver] / src / lib / empthread / ntthread.c
index 1f420fa78853c1c3850463f0c0a0876299d7d56f..3942cbe6d0b8debc5a193b6ef2e8eec111d8a79d 100644 (file)
@@ -276,31 +276,6 @@ loc_Exit_Handler(DWORD fdwCtrlType)
     }
 }
 
-/************************
- * empth_request_shutdown
- *
- * This wakes up the main thread so shutdown can proceed.
- * This is done by signalling hShutdownEvent.
- */
-void
-empth_request_shutdown(void)
-{
-    SetEvent(hShutdownEvent);
-}
-
-/************************
- * loc_BlockMainThread
- *
- * This blocks up the main thread.  loc_WakeupMainThread() is used
- * wakeup the main so shutdown can proceed.
- */
-static void
-loc_BlockMainThread(void)
-{
-    /* Get the MUTEX semaphore, wait the number of MS */
-    WaitForSingleObject(hShutdownEvent, INFINITE);
-}
-
 /************************
  * empth_threadMain
  *
@@ -490,19 +465,12 @@ empth_exit(void)
 {
     empth_t *pThread = TlsGetValue(dwTLSIndex);
 
-    loc_BlockThisThread();
-
     loc_debug("empth_exit");
+    loc_BlockThisThread();
 
-    if (pThread->bMainThread) {
-       loc_BlockMainThread();
-       loc_RunThisThread();
-       shutdwn(0);
-    } else {
-       TlsSetValue(dwTLSIndex, NULL);
-       loc_FreeThreadInfo(pThread);
-       _endthread();
-    }
+    TlsSetValue(dwTLSIndex, NULL);
+    loc_FreeThreadInfo(pThread);
+    _endthread();
 }
 
 /************************
@@ -606,6 +574,27 @@ empth_sleep(time_t until)
     loc_RunThisThread();
 }
 
+/************************
+ * empth_request_shutdown
+ *
+ * This wakes up empth_wait_for_shutdown() so shutdown can proceed.
+ * This is done by signalling hShutdownEvent.
+ */
+void
+empth_request_shutdown(void)
+{
+    SetEvent(hShutdownEvent);
+}
+
+int
+empth_wait_for_shutdown(void)
+{
+    /* Get the MUTEX semaphore, wait the number of MS */
+    WaitForSingleObject(hShutdownEvent, INFINITE);
+
+    loc_RunThisThread();
+    return 0;
+}
 
 /************************
  * empth_sem_create