apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: apr/locks/unix thread_mutex.c
Date Fri, 11 Jan 2002 07:54:03 GMT
wrowe       02/01/10 23:54:03

  Modified:    locks/unix thread_mutex.c
  Log:
    Improve performance about 10% by optimizing the code path
  
  Submitted by:	Brian Pane <brian.pane@cnet.com>
  
  Revision  Changes    Path
  1.6       +38 -24    apr/locks/unix/thread_mutex.c
  
  Index: thread_mutex.c
  ===================================================================
  RCS file: /home/cvs/apr/locks/unix/thread_mutex.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- thread_mutex.c	22 Oct 2001 08:30:08 -0000	1.5
  +++ thread_mutex.c	11 Jan 2002 07:54:03 -0000	1.6
  @@ -128,26 +128,35 @@
       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_lock(&mutex->mutex);
  -    if (rv) {
  +        rv = pthread_mutex_lock(&mutex->mutex);
  +        if (rv) {
   #ifdef PTHREAD_SETS_ERRNO
  -        rv = errno;
  +            rv = errno;
   #endif
  -        return rv;
  -    }
  +            return rv;
  +        }
   
  -#if APR_HAS_THREADS
  -    if (mutex->nested) {
           mutex->owner = apr_os_thread_current();
           mutex->owner_ref = 1;
       }
  +    else {
  +#endif
  +        rv = pthread_mutex_lock(&mutex->mutex);
  +        if (rv) {
  +#ifdef PTHREAD_SETS_ERRNO
  +            rv = errno;
  +#endif
  +            return rv;
  +        }
  +
  +#if APR_HAS_THREADS
  +    }
   #endif
   
       return rv;
  @@ -194,24 +203,29 @@
               if (mutex->owner_ref > 0)
                   return APR_SUCCESS;
           }
  -    }
  -#endif
  -
  -    status = pthread_mutex_unlock(&mutex->mutex);
  -    if (status) {
  +        status = pthread_mutex_unlock(&mutex->mutex);
  +        if (status) {
   #ifdef PTHREAD_SETS_ERRNO
  -        status = errno;
  +            status = errno;
   #endif
  -        return status;
  -    }
  +            return status;
  +        }
   
  -#if APR_HAS_THREADS
  -    if (mutex->nested) {
           memset(&mutex->owner, 0, sizeof mutex->owner);
           mutex->owner_ref = 0;
       }
  +    else {
  +#endif
  +        status = pthread_mutex_unlock(&mutex->mutex);
  +        if (status) {
  +#ifdef PTHREAD_SETS_ERRNO
  +            status = errno;
  +#endif
  +            return status;
  +        }
  +#if APR_HAS_THREADS
  +    }
   #endif
  -    
       return status;
   }
   
  
  
  

Mime
View raw message