httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yann Ylavic <ylavic....@gmail.com>
Subject Re: How to wait on a global lock with timeout
Date Sat, 16 May 2015 17:05:30 GMT
Hi Micha,

On Sat, May 16, 2015 at 5:22 PM, Micha Lenk <micha@lenk.info> wrote:
>
> Sorry, took me a while to give your patch a try. As the patch didn't
> apply cleanly to trunk (ie. SVN rev. 1676013), I assume that it is
> already applied in trunk. So I went ahead without applying your patch.
> Is this correct?

Yes, links point to svn commits in trunk.


>
> I wrote a small test program that should prove me that timed global
> locks work across process boundaries (see attached source). But for some
> reason apr_global_mutex_unlock() return 1 if called in the child
> process. This is the output that I get from the compiled test program:
>
> Trying to get locked mutex... timed out after 1 second (expected)
> Child trying to unlock the mutex got 1 (unexpected)
> Trying to get locked mutex... timed out after 2 seconds (unexpected)
>
> Did I do anything wrong?

A mutex must be unlocked by the thread which locked it (error 1 is EPERM).

Thus you can:
    lock()
    if fork() == 0:
        lock()
    else:
        unlock()

but not:
    lock()
    if fork() == 0:
        unlock()
    else:
        lock()

Regards,
Yann.

Mime
View raw message