You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Xavier Beaudouin <ki...@oav.net> on 2005/01/13 19:01:28 UTC

APR and mutexes ?

Hello there,

I have inside a Apache2 module a call to a non thread safe function. I 
need then to do :

mutex_set();
call_to_non_thread_safe();
unset_mutex();

Now I can do that using POSIX calls, but I really like to use APR calls.

Is there any good doc or even an example module I can use to make such 
work ?

Many thanks to all:)
/Xavier
--
Xavier Beaudouin - Unix System Administrator & Projects Leader.
President of Kazar Organization : http://www.kazar.net/
Please visit http://caudium.net/, home of Caudium & Camas projects


Re: APR and mutexes ?

Posted by Jeff Trawick <tr...@gmail.com>.
On Thu, 13 Jan 2005 19:01:28 +0100, Xavier Beaudouin <ki...@oav.net> wrote:
> Hello there,
> 
> I have inside a Apache2 module a call to a non thread safe function. I
> need then to do :
> 
> mutex_set();
> call_to_non_thread_safe();
> unset_mutex();
> 
> Now I can do that using POSIX calls, but I really like to use APR calls.
> 
> Is there any good doc

apr_thread_mutex.h

> or even an example module I can use to make such
> work ?

$ cd /apache/source/tree
$ grep apr_thread_mutex `find modules -name '*.c'`

These modules will give examples of where in Apache module the
initialization should occur, as well as sample calls during request
processing.

Re: APR and mutexes ?

Posted by Andy Armstrong <an...@hexten.net>.
Xavier Beaudouin wrote:
> Is there any good doc or even an example module I can use to make such 
> work ?

mod_log_rotate for Apache 2 uses mutexes. The source is here:

   http://www.hexten.net/sw/mod_log_rotate/apache2/mod_log_rotate.c

-- 
Andy Armstrong, hexten.net


Re: APR and mutexes ?

Posted by Andy Armstrong <an...@apache.org>.
Xavier Beaudouin wrote:

 > Is there any good doc or even an example module I can use to make 
such work ?


mod_log_rotate for Apache 2 uses mutexes. The source is here:

   http://www.hexten.net/sw/mod_log_rotate/apache2/mod_log_rotate.c

-- 
Andy Armstrong, hexten.net



Re: APR and mutexes ?

Posted by Nick Kew <ni...@webthing.com>.
On Thu, 13 Jan 2005, Xavier Beaudouin wrote:

> I have inside a Apache2 module a call to a non thread safe function. I
> need then to do :
>
> mutex_set();
> call_to_non_thread_safe();
> unset_mutex();
>
> Now I can do that using POSIX calls, but I really like to use APR calls.

Yep.  That's right for a module.  But there's a bit more than that:
to work across all platforms you need

#if APR_HAS_THREADS
   apr_thread_mutex_dosomething(...) ;
#endif

> Is there any good doc or even an example module I can use to make such
> work ?

The doc is in /usr/local/apache/include (or wherever you put your headers).

I recently dealt with this in the apr_dbd package -
see http://www.apache.org/~niq/dbd.html

BTW, doesn't anyone else think it's wrong for apps to have to faff
around with #ifdefs, when it would be trivial for apr_thread_mutex.h
to #define all the functions out when not APR_HAS_THREADS?

BTW2, this looks more appropriate to the modules list than here.

-- 
Nick Kew