This is the mail archive of the cygwin-patches@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] minor pthread fixes



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) ... .

Thanks,
Thomas


2002-04-18  Thomas Pfaff  <tpfaff@gmx.net>

 	* 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
	detached.
	(__pthread_exit): delete thread when it is detached and not
	joined.
	(__pthread_join): Check for deadlock and delete thread when it has
	terminated.
	(__pthread_detach): Set joiner to self when thread state
	changed to detached.

Attachment: pthread_fixes.patch
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]