apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <traw...@attglobal.net>
Subject Re: [PATCH] allow an APR app to choose underlying lock mechanism
Date Mon, 25 Jun 2001 23:02:06 GMT
Justin Erenkrantz <jerenkrantz@ebuilt.com> writes:

> On Mon, Jun 25, 2001 at 04:30:45PM -0400, Jeff Trawick wrote:
> > Did anybody want this done differently?
> 
> What about Read/write locks?  Those would use the same function for
> creation, but none of the values for the methods would be valid
> (except the DEFAULT).

Also note that what is there now is not just lock-flavor-specific but
also OS-specific.  I would think that as there are choices for
different lock flavors on Unix or choices for anything on other APR
platforms that we could add other APR_LOCK_foo enums.

> Would it make more sense to have something that would be more 
> specific to each lock type (mutex, semaphore, read/write locks)?

You tell me :)

I find the whole notion of needing to tell APR which mechanism to use
fairly klunky, and OS-specific stuff like this really klunky.  Given
that premise, I don't have a big problem with APR_LOCK_DEFAULT being
the only thing valid for various platforms and/or lock flavors.

> [ See one note about the patch below...]
> 
> > Index: test/testlock.c
> > ===================================================================
> > RCS file: /home/cvs/apr/test/testlock.c,v
> > retrieving revision 1.3
> > diff -u -r1.3 testlock.c
> > --- test/testlock.c	2001/06/06 22:25:43	1.3
> > +++ test/testlock.c	2001/06/25 20:27:22
> > @@ -143,7 +143,7 @@
> >      printf("RW Lock Tests\n");
> >      printf("%-60s", "    Initializing the RW lock");
> >      s1 = apr_lock_create(&thread_rw_lock, APR_READWRITE, APR_INTRAPROCESS,
> > -                         "lock.file", pool);
> > +                         APR_LOCK_CREATE, "lock.file", pool);
> >      if (s1 != APR_SUCCESS) {
> >          printf("Failed!\n");
> >          return s1;
> > @@ -191,7 +191,7 @@
> >      printf("Exclusive lock test\n");
> >      printf("%-60s", "    Initializing the lock");
> >      s1 = apr_lock_create(&thread_lock, APR_MUTEX, APR_INTRAPROCESS, 
> > -                         "lock.file", pool); 
> > +                         APR_LOCK_CREATE, "lock.file", pool); 
> >  
> >      if (s1 != APR_SUCCESS) {
> >          printf("Failed!\n");
> > @@ -239,8 +239,8 @@
> >   
> >      printf("Testing multiple locking\n");
> >      printf("%-60s","    Creating the lock we'll use");
> > -    if ((rv = apr_lock_create(&multi, APR_MUTEX, APR_LOCKALL,"multi.lock",
> > -                        pool)) != APR_SUCCESS) {
> > +    if ((rv = apr_lock_create(&multi, APR_MUTEX, APR_LOCKALL,APR_LOCK_CREATE,
> > +                              "multi.lock", pool)) != APR_SUCCESS) {
> >          printf("Failed!\n");
> >          return rv;
> >      }
> 
> Shouldn't these be APR_LOCK_DEFAULT, or am I missing something?  

You bet!!!!!!!!!!!!!!!!!!! I dunno what I'm doing :)  Also, I need to
see why it worked (at least I think it did).

-- 
Jeff Trawick | trawick@attglobal.net | PGP public key at web site:
       http://www.geocities.com/SiliconValley/Park/9289/
             Born in Roswell... married an alien...


Mime
View raw message