apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hans-Peter Weidinger <hans-pe...@hp-weidinger.at>
Subject Re: apr_proc_trylock for linux
Date Mon, 15 May 2006 16:09:00 GMT
Hi Chris,

thanks for the info. I feared that the trylock will not be available for 
unixes (especially linux) permanently.

I'll try the current Repository-Version. But i can only add them to the 
software if the
mechanisms are in the release version of APR (hopefolly soon).

br

Hans-Peter

Chris Darroch schrieb:
> Hans-Peter Weidinger wrote:
>
>   
>> @anyone on the list:
>> Does anyone know, if apr_proc_trylock a subject to be added for linux (i 
>> could live with that) or is this permanent?
>>     
>
>    The APR trunk now contains a set of trylock functions for Unixes;
> by all means give them a test run.  There are five possible underlying
> locking mechanisms, not all of which are available on every Unix
> platform; APR configuration will choose a default one.  Some of these
> mechanisms recover gracefully after a process dies while holding
> a lock, and others do not.  My own tests are summarized here:
>
> http://issues.apache.org/bugzilla/attachment.cgi?id=17772
>
> (I believe the latest Linux kernels with a bleeding-edge libc
> have pthread semantics more like Solaris, BTW.)
>
>    That all said, process mutexes may not serve your purpose ...
>
>
> Danial May wrote:
>
>   
>> The apr proc mutex's seem to favor being inherited rather than working
>> between two unrelated processes.
>>     
>
>    Yes, and the child process should call apr_proc_mutex_child_init()
> before trying to use any process mutexes.  (In practice, this is
> because one of the five possible Unix locking mechanisms, flock(),
> requires initialization.  So does OS/2, it seems.)
>
>    To be platform agnostic, therefore, this call should always be made;
> that in turn implies that unrelated processes can't share locks.  See
> the remarks under:
>
> http://apr.apache.org/docs/apr/group__apr__proc__mutex.html#ga2
>
>
>   
>> Intention: If a second instance of the process is started, the command 
>> line parameter should be given to the first
>> instance and then terminate immediately.
>>     
>
>    Just as a suggestion, could you do something like what Apache httpd
> does to achieve this?  The running process writes its process ID into
> a file and it removes the file when it exits.  If another process is
> started, it reads the pid from the file and send an appropriate signal
> (based on the command line parameters) to the running process, then
> exits.
>
> Chris.
>
>   


-- 

Weidinger Hans-Peter
------------------------------------------------------------------------
Weidinger Hans-Peter Softwaredienstleistungen und Beratung
Sebekstrasse 21
4400 Steyr

Tel.: +43 676 9134882
Email: hans-peter.weidinger@hp-weidinger.at 
<mailto:hans-peter.weidinger@hp-weidinger.at>
Weidinger Hans-Peter
------------------------------------------------------------------------

Mime
View raw message