You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by S�bastien Bonnegent <sb...@mediapps.com> on 2002/08/22 14:38:50 UTC

Do you know apr_anylock_t ?

Ian Holsman wrote:
IH> Sébastien Bonnegent wrote:
IH> > Hi,
IH> > 
IH> > My purpose is sharing a data structure.
IH> > For example with an array:
IH> > - httpd creation, my_array is empty
IH> > - there are 8 servers launched
IH> > - server1 add an entry named (X)
IH> > - server5 add an entry
IH> > - server3 read an entry
IH> > - server7 remove the (X) entry
IH> > After this, my_array contains one line which is the server5 entry.
IH> > 
IH> you will need to create a shared memory area to put your structure in,
IH> and have some kind of locking mechanism to ensure you don't have any
IH> race conditions.

sure, to lock the shared memory area, I have to use the apr_anylock_t structure
but I haven't found documentation on the different lock type...
and it seems that this structure is not very used in the apache source...

Are there someone who know the different lock type ?

IH> have a look at apr-utils/misc/apr_rmm.c & apr_queue.c for an idea on
IH> what it required.

thank you. I haven't found apr_queue.c but apr_rmm.c is perfect.

seß - sinad
-- 
GPG uid: 0xCB92591D  ICQ: 60143970
LINUX - because life is too short to reboot !
-- Fortune:
Q:	Why should you always serve a Southern Carolina football man
	soup in a plate?
A:	'Cause if you give him a bowl, he'll throw it away.

Re: Do you know apr_anylock_t ?

Posted by Aaron Bannert <aa...@clove.org>.
On Thu, Aug 22, 2002 at 02:38:50PM +0200, Sébastien Bonnegent wrote:
> sure, to lock the shared memory area, I have to use the apr_anylock_t structure
> but I haven't found documentation on the different lock type...
> and it seems that this structure is not very used in the apache source...

There is only one type of shared memory in APR: apr_shm.h. It allows you
to request regions of shared memory to use between httpd children. If
you know the sizes of the structures you will store in there, you can
treat it like a big array or a big blob of memory. If OTOH you need to
do memory allocation and deallocation inside of that block, then you
can use the apr_rmm.h interface to manage that memory.

> Are there someone who know the different lock type ?

There are three types of locks. If you are using shared memory and
you want it to protect you whether you're using the prefork or worker
MPM, then the only one you should use is apr_global_mutex.h. The
apr_anylock_t structure is an abstraction of all the apr lock types,
and is only necessary for telling the apr_rmm.h interface how it
should protect its internal structures.

[If you have more questions, feel free to follow this up on the
dev@apr.apache.org list.]

-aaron

Re: Do you know apr_anylock_t ?

Posted by Aaron Bannert <aa...@clove.org>.
On Thu, Aug 22, 2002 at 02:38:50PM +0200, Sébastien Bonnegent wrote:
> sure, to lock the shared memory area, I have to use the apr_anylock_t structure
> but I haven't found documentation on the different lock type...
> and it seems that this structure is not very used in the apache source...

There is only one type of shared memory in APR: apr_shm.h. It allows you
to request regions of shared memory to use between httpd children. If
you know the sizes of the structures you will store in there, you can
treat it like a big array or a big blob of memory. If OTOH you need to
do memory allocation and deallocation inside of that block, then you
can use the apr_rmm.h interface to manage that memory.

> Are there someone who know the different lock type ?

There are three types of locks. If you are using shared memory and
you want it to protect you whether you're using the prefork or worker
MPM, then the only one you should use is apr_global_mutex.h. The
apr_anylock_t structure is an abstraction of all the apr lock types,
and is only necessary for telling the apr_rmm.h interface how it
should protect its internal structures.

[If you have more questions, feel free to follow this up on the
dev@apr.apache.org list.]

-aaron