From ab9f05fd540b3eff6456f886edda87cb95bfbadc Mon Sep 17 00:00:00 2001
From: rpj <rpj>
Date: Tue, 23 Mar 1999 19:43:43 +0000
Subject: Wed Mar 24 11:32:07 1999  Ross Johnson  <rpj@swan.canberra.edu.au> 
 * misc.c (CancelableWait): Initialise exceptionInformation[2]. 
 (pthread_self): Get a real Win32 thread handle for implicit threads. 	*
 cancel.c (pthread_testcancel): Initialise exceptionInformation[2]. 	*
 implement.h (SE_INFORMATION): Fix values. 	* private.c
 (_pthread_threadDestroy): Close the thread handle. Fri Mar 19 12:57:27 1999 
 Ross Johnson  <rpj@swan.canberra.edu.au> 	* cancel.c (comments): Update
 and cleanup. Fri Mar 19 09:12:59 1999  Ross Johnson 
 <rpj@ixobrychus.canberra.edu.au> 	* private.c (_pthread_threadStart):
 status returns PTHREAD_CANCELED. 	* pthread.h (PTHREAD_CANCELED):
 defined.

---
 ChangeLog   | 15 +++++++++++++++
 README      |  4 ++--
 cancel.c    | 15 ++++++---------
 implement.h |  9 ++-------
 misc.c      | 21 +++++++++++++++------
 private.c   | 22 ++++++++++------------
 6 files changed, 50 insertions(+), 36 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9bf3ccc..90c032c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+Wed Mar 24 11:32:07 1999  Ross Johnson  <rpj@swan.canberra.edu.au>
+
+	* misc.c (CancelableWait): Initialise exceptionInformation[2].
+	(pthread_self): Get a real Win32 thread handle for implicit threads.
+
+	* cancel.c (pthread_testcancel): Initialise exceptionInformation[2].
+
+	* implement.h (SE_INFORMATION): Fix values.
+
+	* private.c (_pthread_threadDestroy): Close the thread handle.
+
+Fri Mar 19 12:57:27 1999  Ross Johnson  <rpj@swan.canberra.edu.au>
+
+	* cancel.c (comments): Update and cleanup.
+
 Fri Mar 19 09:12:59 1999  Ross Johnson  <rpj@ixobrychus.canberra.edu.au>
 
 	* private.c (_pthread_threadStart): status returns PTHREAD_CANCELED.
diff --git a/README b/README
index c0b7563..ca32d26 100644
--- a/README
+++ b/README
@@ -8,8 +8,8 @@ and conditions.
 Mailing list
 ------------
 
-There is a mailing list for discussing pthreads on Win32. To join, send
-enail to:
+There is a mailing list for discussing pthreads on Win32. To join, send email
+to:
 
 	pthreads-win32-subscribe@sourceware.cygnus.com
 
diff --git a/cancel.c b/cancel.c
index 8b93705..dac8e66 100644
--- a/cancel.c
+++ b/cancel.c
@@ -26,10 +26,6 @@
 #include "pthread.h"
 #include "implement.h"
 
-/*
- * Code contributed by John E. Bossom <JEB>.
- */
-
 int
 pthread_setcancelstate (int state, int *oldstate)
      /*
@@ -106,7 +102,7 @@ pthread_setcanceltype (int type, int *oldtype)
       *              PTHREAD_CANCEL_DEFERRED
       *                      only deferred cancelation is allowed,
       *
-      *              PTHRAD_CANCEL_ASYNCHRONOUS
+      *              PTHREAD_CANCEL_ASYNCHRONOUS
       *                      Asynchronous cancellation is allowed
       *
       *
@@ -201,6 +197,7 @@ pthread_testcancel (void)
 
 	      exceptionInformation[0] = (DWORD) (0);
 	      exceptionInformation[1] = (DWORD) (0);
+	      exceptionInformation[2] = (DWORD) (0);
 
 	      RaiseException (
 			       EXCEPTION_PTHREAD_SERVICES,
@@ -242,7 +239,7 @@ pthread_cancel (pthread_t thread)
       *                wait for termination of 'thread' if necessary.
       *
       * RESULTS
-      *              0               successfully created semaphore,
+      *              0               successfully requested cancellation,
       *              ESRCH           no thread found corresponding to 'thread',
       *
       * ------------------------------------------------------
@@ -252,7 +249,9 @@ pthread_cancel (pthread_t thread)
 
   if (thread != NULL)
     {
-
+      /*
+       * Set for deferred cancellation.
+       */
       if (!SetEvent (thread->cancelEvent))
 	{
 	  result = ESRCH;
@@ -271,5 +270,3 @@ pthread_cancel (pthread_t thread)
   return (result);
 }
 
-/* </JEB> */
-
diff --git a/implement.h b/implement.h
index 3e9ff50..7740e0c 100644
--- a/implement.h
+++ b/implement.h
@@ -27,10 +27,6 @@
 #ifndef _IMPLEMENT_H
 #define _IMPLEMENT_H
 
-/*
- * Code contributed by John E. Bossom <JEB>.
- */
-
 
 typedef struct ThreadParms ThreadParms;
 typedef struct ThreadKeyAssoc ThreadKeyAssoc;
@@ -120,8 +116,8 @@ struct ThreadKeyAssoc {
  */
 #define SE_SUCCESS              0x00
 #define SE_INFORMATION	        0x01
-#define SE_WARNING              0x10
-#define SE_ERROR                0x11
+#define SE_WARNING              0x02
+#define SE_ERROR                0x03
 
 #define MAKE_SOFTWARE_EXCEPTION( _severity, _facility, _exception ) \
 ( (DWORD) ( ( (_severity) << 30 ) |	/* Severity code	*/ \
@@ -221,7 +217,6 @@ int _pthread_sem_post (_pthread_sem_t * sem);
 }
 #endif /* __cplusplus */
 
-/* </JEB> */
 
 /*
  * Check for old and new versions of cygwin. See the FAQ file:
diff --git a/misc.c b/misc.c
index cdf6ec8..a37db5c 100644
--- a/misc.c
+++ b/misc.c
@@ -26,9 +26,6 @@
 #include "pthread.h"
 #include "implement.h"
 
-/*
- * Code contributed by John E. Bossom <JEB>.
- */
 
 int
 pthread_once (
@@ -158,14 +155,26 @@ pthread_self (void)
        * executing thread.
        */
       self = (pthread_t) calloc (1, sizeof (*self));
+
       if (self != NULL)
 	{
-
 	  self->implicit = 1;
 	  self->detachState = PTHREAD_CREATE_DETACHED;
 
 	  self->thread = GetCurrentThreadId ();
-	  self->threadH = GetCurrentThread ();
+
+	  if( !DuplicateHandle(
+			       GetCurrentProcess(),
+			       GetCurrentThread(),
+			       GetCurrentProcess(),
+			       &self->threadH,
+			       0,
+			       FALSE,
+			       DUPLICATE_SAME_ACCESS ) )
+	    {
+	      free( self );
+	      return (NULL);
+	    }
 	}
 
       pthread_setspecific (_pthread_selfThreadKey, self);
@@ -307,6 +316,7 @@ CancelableWait (HANDLE waitHandle, DWORD timeout)
 
               exceptionInformation[0] = (DWORD) (0);
               exceptionInformation[1] = (DWORD) (0);
+              exceptionInformation[2] = (DWORD) (0);
 
               RaiseException (
                                EXCEPTION_PTHREAD_SERVICES,
@@ -351,5 +361,4 @@ pthreadCancelableTimedWait (HANDLE waitHandle, DWORD timeout)
   return (CancelableWait(waitHandle, timeout));
 }
 
-/* </JEB> */
 
diff --git a/private.c b/private.c
index 9ffd1b3..dd6890c 100644
--- a/private.c
+++ b/private.c
@@ -33,9 +33,6 @@
 #include "pthread.h"
 #include "implement.h"
 
-/*
- * Code contributed by John E. Bossom <JEB>.
- */
 
 int
 _pthread_processInitialize (void)
@@ -224,7 +221,7 @@ _pthread_threadStart (ThreadParms * threadParms)
    */
   return (status);
 
-}				/* threadStart */
+}				/* _pthread_threadStart */
 
 void
 _pthread_threadDestroy (pthread_t thread)
@@ -238,10 +235,15 @@ _pthread_threadDestroy (pthread_t thread)
 	  CloseHandle (thread->cancelEvent);
 	}
 
+      if( thread->threadH != 0 )
+	{
+	  CloseHandle( thread->threadH );
+	}
+
       free (thread);
     }
 
-}				/* threadDestroy */
+}				/* _pthread_threadDestroy */
 
 int
 _pthread_tkAssocCreate (ThreadKeyAssoc ** assocP,
@@ -347,7 +349,7 @@ FAIL0:
 
   return (result);
 
-}				/* tkAssocCreate */
+}				/* _pthread_tkAssocCreate */
 
 
 void
@@ -376,7 +378,7 @@ _pthread_tkAssocDestroy (ThreadKeyAssoc * assoc)
       free (assoc);
     }
 
-}				/* tkAssocDestroy */
+}				/* _pthread_tkAssocDestroy */
 
 
 void
@@ -507,9 +509,5 @@ _pthread_callUserDestroyRoutines (pthread_t thread)
 	}
     }
 
-}				/* callUserDestroyRoutines */
-
-/* </JEB> */
-
-
+}				/* _pthread_callUserDestroyRoutines */
 
-- 
cgit v1.2.3