apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aa...@apache.org
Subject cvs commit: apr/locks/unix thread_mutex.c
Date Fri, 11 Jan 2002 15:04:35 GMT
aaron       02/01/11 07:04:35

  Modified:    locks/unix thread_mutex.c
  Log:
  Add Brian Pane's 10% performance improvement logic to trylock() also.
  
  Revision  Changes    Path
  1.7       +21 -13    apr/locks/unix/thread_mutex.c
  
  Index: thread_mutex.c
  ===================================================================
  RCS file: /home/cvs/apr/locks/unix/thread_mutex.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- thread_mutex.c	11 Jan 2002 07:54:03 -0000	1.6
  +++ thread_mutex.c	11 Jan 2002 15:04:34 -0000	1.7
  @@ -167,25 +167,33 @@
       apr_status_t rv;
   
   #if APR_HAS_THREADS
  -    if (mutex->nested && apr_os_thread_equal(mutex->owner,
  -                                             apr_os_thread_current())) {
  -        mutex->owner_ref++;
  -        return APR_SUCCESS;
  -    }
  -#endif
  +    if (mutex->nested) {
  +        if (apr_os_thread_equal(mutex->owner, apr_os_thread_current())) {
  +            mutex->owner_ref++;
  +            return APR_SUCCESS;
  +        }
   
  -    rv = pthread_mutex_trylock(&mutex->mutex);
  -    if (rv) {
  +        rv = pthread_mutex_trylock(&mutex->mutex);
  +        if (rv) {
   #ifdef PTHREAD_SETS_ERRNO
  -        rv = errno;
  +            rv = errno;
   #endif
  -        return (rv == EBUSY) ? APR_EBUSY : rv;
  -    }
  +            return (rv == EBUSY) ? APR_EBUSY : rv;
  +        }
   
  -#if APR_HAS_THREADS
  -    if (mutex->nested) {
           mutex->owner = apr_os_thread_current();
           mutex->owner_ref = 1;
  +    }
  +    else {
  +#endif
  +        rv = pthread_mutex_trylock(&mutex->mutex);
  +        if (rv) {
  +#ifdef PTHREAD_SETS_ERRNO
  +            rv = errno;
  +#endif
  +            return (rv == EBUSY) ? APR_EBUSY : rv;
  +        }
  +#if APR_HAS_THREADS
       }
   #endif
   
  
  
  

Mime
View raw message