[PATCH] minor pthread fixes
Thu Apr 18 03:11:00 GMT 2002
This patch contains some small pthread fixes:
1. the pthread class allocated in __pthread_create never was freed. This
resulted in a memory leak and an unclosed handle.
Depending on the state of of the thread it is deleted now in
__pthread_exit or __pthread_join
2. The InterlockedIncrement (&MT_INTERFACE->threadcount) in
__pthread_create is misplaced. If the newly created thread terminates
fast enough the threadcount will be decremented before it was
incremented, which will result in an exit from __pthread_exit instead
of an ExitThread.
Comments are very welcome, because i like to add more patches regarding
cancellation which is incomplete, a better mutex implementation (the
current one has only recursive mutexes and is slow on win9x) ... .
2002-04-18 Thomas Pfaff <email@example.com>
* thread.h (pthread::joiner): New member.
* thread.cc (pthread::pthread): Initialize joiner to NULL
(pthread::create): Increment of thread counter moved from
__pthread_create to this location.
(__pthread_create): Increment thread counter removed.
(thread_init_wrapper): Set joiner to self when thread was created
(__pthread_exit): delete thread when it is detached and not
(__pthread_join): Check for deadlock and delete thread when it has
(__pthread_detach): Set joiner to self when thread state
changed to detached.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 3716 bytes
More information about the Cygwin-patches