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 global_mutex.c
Date Tue, 29 Oct 2002 22:54:23 GMT
wrowe       2002/10/29 14:54:23

  Modified:    locks/unix global_mutex.c
  Log:
    Whoa Nelly!  Lots of errors in the global mutex failure cases.  We have
    to unlock the outer lock when the inner lock fails!!!  Many deadlock
    situations existed prior to this patch.
  
  Revision  Changes    Path
  1.8       +32 -17    apr/locks/unix/global_mutex.c
  
  Index: global_mutex.c
  ===================================================================
  RCS file: /home/cvs/apr/locks/unix/global_mutex.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- global_mutex.c	8 May 2002 13:30:11 -0000	1.7
  +++ global_mutex.c	29 Oct 2002 22:54:22 -0000	1.8
  @@ -64,19 +64,20 @@
       apr_global_mutex_t *m = (apr_global_mutex_t *)data;
       apr_status_t rv;
   
  +    rv = apr_proc_mutex_destroy(m->proc_mutex);
  +
   #if APR_HAS_THREADS
       if (m->thread_mutex) {
  -        rv = apr_thread_mutex_destroy(m->thread_mutex);
           if (rv != APR_SUCCESS) {
  -            return rv;
  +            (void)apr_thread_mutex_destroy(m->thread_mutex);
  +        }
  +        else {
  +            rv = apr_thread_mutex_destroy(m->thread_mutex);
           }
       }
   #endif /* APR_HAS_THREADS */
  -    rv = apr_proc_mutex_destroy(m->proc_mutex);
  -    if (rv != APR_SUCCESS) {
  -       return rv;
  -    }
  -    return APR_SUCCESS;
  +
  +    return rv;
   }
   
   APR_DECLARE(apr_status_t) apr_global_mutex_create(apr_global_mutex_t **mutex,
  @@ -103,6 +104,7 @@
           rv = apr_thread_mutex_create(&m->thread_mutex,
                                        APR_THREAD_MUTEX_DEFAULT, m->pool);
           if (rv != APR_SUCCESS) {
  +            rv = apr_proc_mutex_destroy(m->proc_mutex);
               return rv;
           }
       }
  @@ -134,11 +136,18 @@
           }
       }
   #endif /* APR_HAS_THREADS */
  +
       rv = apr_proc_mutex_lock(mutex->proc_mutex);
  +
  +#if APR_HAS_THREADS
       if (rv != APR_SUCCESS) {
  -        return rv;
  +        if (mutex->thread_mutex) {
  +            (void)apr_thread_mutex_unlock(mutex->thread_mutex);
  +        }
       }
  -    return APR_SUCCESS;
  +#endif /* APR_HAS_THREADS */
  +
  +    return rv;
   }
   
   APR_DECLARE(apr_status_t) apr_global_mutex_trylock(apr_global_mutex_t *mutex)
  @@ -153,11 +162,18 @@
           }
       }
   #endif /* APR_HAS_THREADS */
  +
       rv = apr_proc_mutex_trylock(mutex->proc_mutex);
  +
  +#if APR_HAS_THREADS
       if (rv != APR_SUCCESS) {
  -        return rv;
  +        if (mutex->thread_mutex) {
  +            (void)apr_thread_mutex_unlock(mutex->thread_mutex);
  +        }
       }
  -    return APR_SUCCESS;
  +#endif /* APR_HAS_THREADS */
  +
  +    return rv;
   }
   
   APR_DECLARE(apr_status_t) apr_global_mutex_unlock(apr_global_mutex_t *mutex)
  @@ -165,18 +181,17 @@
       apr_status_t rv;
   
       rv = apr_proc_mutex_unlock(mutex->proc_mutex);
  -    if (rv != APR_SUCCESS) {
  -        return rv;
  -    }
   #if APR_HAS_THREADS
       if (mutex->thread_mutex) {
  -        rv = apr_thread_mutex_unlock(mutex->thread_mutex);
           if (rv != APR_SUCCESS) {
  -            return rv;
  +            (void)apr_thread_mutex_unlock(mutex->thread_mutex);
  +        }
  +        else {
  +            rv = apr_thread_mutex_unlock(mutex->thread_mutex);
           }
       }
   #endif /* APR_HAS_THREADS */
  -    return APR_SUCCESS;
  +    return rv;
   }
   
   APR_DECLARE(apr_status_t) apr_os_global_mutex_get(apr_os_global_mutex_t *ospmutex,
  
  
  

Mime
View raw message