You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by aa...@apache.org on 2002/11/18 02:59:03 UTC

cvs commit: apr/locks/unix proc_mutex.c

aaron       2002/11/17 17:59:03

  Modified:    include/arch/unix proc_mutex.h
               locks/unix proc_mutex.c
  Log:
  Rip out buggy nested-mutex code from apr_proc_mutex. This should fix subtle
  problems on MP boxes (Linux in particular).
  
  Revision  Changes    Path
  1.10      +0 -7      apr/include/arch/unix/proc_mutex.h
  
  Index: proc_mutex.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/unix/proc_mutex.h,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- proc_mutex.h	28 Jun 2002 11:38:50 -0000	1.9
  +++ proc_mutex.h	18 Nov 2002 01:59:03 -0000	1.10
  @@ -160,13 +160,6 @@
   #if APR_HAS_PROC_PTHREAD_SERIALIZE
       pthread_mutex_t *pthread_interproc;
   #endif
  -#if APR_HAS_THREADS
  -    /* APR doesn't have threads, no sense in having a thread lock mechanism.
  -     */
  -
  -    apr_os_thread_t owner;
  -    int owner_ref;
  -#endif
   };
   
   void apr_proc_mutex_unix_setup_lock(void);
  
  
  
  1.20      +3 -58     apr/locks/unix/proc_mutex.c
  
  Index: proc_mutex.c
  ===================================================================
  RCS file: /home/cvs/apr/locks/unix/proc_mutex.c,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- proc_mutex.c	30 Jun 2002 04:04:42 -0000	1.19
  +++ proc_mutex.c	18 Nov 2002 01:59:03 -0000	1.20
  @@ -882,72 +882,17 @@
   
   APR_DECLARE(apr_status_t) apr_proc_mutex_lock(apr_proc_mutex_t *mutex)
   {
  -    apr_status_t rv;
  -
  -#if APR_HAS_THREADS
  -    if (apr_os_thread_equal(mutex->owner, apr_os_thread_current())) {
  -        mutex->owner_ref++;
  -        return APR_SUCCESS;
  -    }
  -#endif
  -
  -    if ((rv = mutex->meth->acquire(mutex)) != APR_SUCCESS) {
  -        return rv;
  -    }
  -
  -#if APR_HAS_THREADS
  -    mutex->owner = apr_os_thread_current();
  -    mutex->owner_ref = 1;
  -#endif
  -
  -    return APR_SUCCESS;
  +    return mutex->meth->acquire(mutex);
   }
   
   APR_DECLARE(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex)
   {
  -    apr_status_t rv;
  -
  -#if APR_HAS_THREADS
  -    if (apr_os_thread_equal(mutex->owner, apr_os_thread_current())) {
  -        mutex->owner_ref++;
  -        return APR_SUCCESS;
  -    }
  -#endif
  -
  -    if ((rv = mutex->meth->tryacquire(mutex)) != APR_SUCCESS) {
  -        return rv;
  -    }
  -
  -#if APR_HAS_THREADS
  -    mutex->owner = apr_os_thread_current();
  -    mutex->owner_ref = 1;
  -#endif
  -
  -    return APR_SUCCESS;
  +    return mutex->meth->tryacquire(mutex);
   }
   
   APR_DECLARE(apr_status_t) apr_proc_mutex_unlock(apr_proc_mutex_t *mutex)
   {
  -    apr_status_t rv;
  -
  -#if APR_HAS_THREADS
  -    if (apr_os_thread_equal(mutex->owner, apr_os_thread_current())) {
  -        mutex->owner_ref--;
  -        if (mutex->owner_ref > 0)
  -            return APR_SUCCESS;
  -    }
  -#endif
  -
  -    if ((rv = mutex->meth->release(mutex)) != APR_SUCCESS) {
  -        return rv;
  -    }
  -
  -#if APR_HAS_THREADS
  -    memset(&mutex->owner, 0, sizeof mutex->owner);
  -    mutex->owner_ref = 0;
  -#endif
  -    
  -    return APR_SUCCESS;
  +    return mutex->meth->release(mutex);
   }
   
   APR_DECLARE(apr_status_t) apr_proc_mutex_destroy(apr_proc_mutex_t *mutex)