You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Mladen Turk <mt...@apache.org> on 2004/08/27 11:44:01 UTC

[PATCH] WIN32 - fix apr_thread_join (PR: 28460)

Patch fixes the thread join for already finished thread.
Unlike Mark Khon's patch, this patch simply checks if the
thread has been closed.

Index: thread.c
===================================================================
RCS file: /home/cvspublic/apr/threadproc/win32/thread.c,v
retrieving revision 1.57
diff -u -r1.57 thread.c
--- thread.c	10 Jun 2004 10:57:25 -0000	1.57
+++ thread.c	27 Aug 2004 09:28:16 -0000
@@ -135,6 +135,7 @@
  #ifndef _WIN32_WCE
      if (thd->td) {
          CloseHandle(thd->td);
+        thd->td = NULL;
      }
      _endthreadex(0);
  #else
@@ -147,7 +148,12 @@
                                            apr_thread_t *thd)
  {
      apr_status_t rv;
-
+
+    if (!thd->td) {
+        /* The thead has already been closed */
+        *retval = thd->exitval;
+        return APR_SUCCESS;
+    }
      rv = WaitForSingleObject(thd->td, INFINITE);
      if ( rv == WAIT_OBJECT_0 || rv == WAIT_ABANDONED) {
          *retval = thd->exitval;