apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Max Khon <f...@samodelkin.net>
Subject Re: apr win32 bug [PATCH]
Date Mon, 02 Aug 2004 05:39:04 GMT
Hi!

On Sun, Aug 01, 2004 at 08:07:23PM -0500, William A. Rowe, Jr. wrote:

> Although I agree, with your patch in spirit, if apr_thread_join is never
> called, your patch -can- leak handles like a sieve :(
> 
> Did we ever define that apr_thread_create() must be partnered with
> an apr_thread_join?

Yes.

>From pthread_join manual page on Linux:

       When  a  joinable  thread  terminates,  its  memory  resources  (thread
       descriptor and stack) are not deallocated until another thread performs
       pthread_join on it. Therefore, pthread_join must  be  called  once  for
       each joinable thread created to avoid memory leaks.

In other words you MUST call apr_thread_join when underlying implementation
is pthreads.

> If not, it seems we need a clever way to mark
> the apr_thread_t HANDLE member as destroyed, and allow the
> apr_thread_join to simply return immediately.

This would be an overkill.

Please look here as well:
http://issues.apache.org/bugzilla/show_bug.cgi?id=28460 

> Bill
> 
> At 04:52 PM 7/31/2004, Max Khon wrote:
> >Hi!
> >
> >apr_thread_join for win32 is implemented incorrectly:
> >thread handle is destroyed too early (in apr_thread_exit).
> >If apr_thread_exit() is called before apr_thread_join() and
> >new object is created (thread handle is reused) before
> >calling apr_thread_join(), apr_thread_join() will possibly wait
> >on invalid handle.
> >
> >Patch is attached.

Mime
View raw message