Hi Thomas! It's great to see someone else also interested in pthreads. I look forward to your work on cancellation - that's been in my TODO list for far too long.
re: 1. Good catch, this definitely needs fixing. Also an excellent catch on pthread_join (pthread_self(),...) Regarding 2:, again a good catch. I'll commit this to CVS this weekend, I've a bit of spare time coming up. Rob > -----Original Message----- > From: Thomas Pfaff [mailto:[EMAIL PROTECTED]] > Sent: Thursday, April 18, 2002 8:11 PM > To: [EMAIL PROTECTED] > Subject: [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 <[EMAIL PROTECTED]> > > * 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. > >