apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matthew Kaufman" <matt...@matthew.at>
Subject apr_thread_once behavior - win32
Date Sat, 25 Feb 2006 05:14:01 GMT

I was recently reviewing apr for use in a project, and came across the
following issue:

 pthread_once has the following behavior (from the man page):
    The first call to pthread_once() by any thread in a process, with a
given
    once_control, will call the init_routine() with no arguments.
Subsequent
    calls to pthread_once() with the same once_control will not call the
    init_routine().  On return from pthread_once(), it is guaranteed that
    init_routine() has completed. 

 apr gives the same behavior when used with pthreads. however, on win32, the
apr implementation does NOT appear to provide the final guarantee, but
instead appears to return immediately if another thread has started the init
routine, rather than wait for the other thread to finish their call to the
init routine (and release a corresponding underlying mutex, which is how the
correct version would need to be implemented).

 I would suggest that this behavior is incorrect, given what one wants from
an "init routine" most of the time.

Matthew Kaufman
matthew@matthew.at


Mime
View raw message