You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by br...@apache.org on 2002/04/28 05:21:24 UTC

cvs commit: apr/locks/unix thread_mutex.c

brianp      02/04/27 20:21:24

  Modified:    locks/unix thread_mutex.c
  Log:
  Optimization: rearranged the mutex lock/unlock code to
  eliminate a conditional branch  on platforms where PTHREAD_SETS_ERRNO
  is not defined (at present, this means everything except OS/390)
  
  Revision  Changes    Path
  1.10      +8 -10     apr/locks/unix/thread_mutex.c
  
  Index: thread_mutex.c
  ===================================================================
  RCS file: /home/cvs/apr/locks/unix/thread_mutex.c,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- thread_mutex.c	13 Mar 2002 20:39:21 -0000	1.9
  +++ thread_mutex.c	28 Apr 2002 03:21:24 -0000	1.10
  @@ -143,19 +143,17 @@
   
           mutex->owner = apr_os_thread_current();
           mutex->owner_ref = 1;
  +        return rv;
       }
       else {
           rv = pthread_mutex_lock(&mutex->mutex);
  -        if (rv) {
   #ifdef PTHREAD_SETS_ERRNO
  +        if (rv) {
               rv = errno;
  -#endif
  -            return rv;
           }
  -
  +#endif
  +        return rv;
       }
  -
  -    return rv;
   }
   
   APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex)
  @@ -212,17 +210,17 @@
   
           memset(&mutex->owner, 0, sizeof mutex->owner);
           mutex->owner_ref = 0;
  +        return status;
       }
       else {
           status = pthread_mutex_unlock(&mutex->mutex);
  -        if (status) {
   #ifdef PTHREAD_SETS_ERRNO
  +        if (status) {
               status = errno;
  -#endif
  -            return status;
           }
  +#endif
  +        return status;
       }
  -    return status;
   }
   
   APR_DECLARE(apr_status_t) apr_thread_mutex_destroy(apr_thread_mutex_t *mutex)