httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yann Ylavic <>
Subject Re: How to wait on a global lock with timeout
Date Tue, 30 Sep 2014 15:30:45 GMT
Hi Micha,

On Mon, Sep 29, 2014 at 3:18 PM, Micha Lenk <> wrote:
> in an Apache module I am in the need to wait for a global lock (e.g. an
> apr_global_mutex_t), but in theory the lock might not get released by the
> other process in a timely manner, so I would like to limit the time to wait
> for the lock. What do you suggest me to do?

I have been working on a patch to provide
apr_[thread/proc]_mutex_timedlock() in APR, but did not finish the
work mostly because of APR_ENOTIMPL on some mutex mechanisms (mainly
Windows CRITICAL_SECTIONs which lack the functionality, making the APR
abstraction quite useless IMO, or at least unix specific). Maybe I'll
have a new look at it these days if I have the time to.

For now you may have the possibility to use native mutex functions
(eg. pthread_mutex_timedlock or WaitForSingleObject) with the native
object retrieved by ap_os_[thread/proc]_mutex_get(), but this requires
either to create the mutex with a mechanism supporting the timeout, or
the existing mutex to have such a mechanism.

Hence this may be non-portable code, or with many APR_HAS_*_SERIALIZE,
and still the problem with platforms that don't support it...


View raw message