apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jor...@apache.org
Subject cvs commit: apr/locks/unix thread_rwlock.c
Date Fri, 03 Oct 2003 15:14:38 GMT
jorton      2003/10/03 08:14:38

  Modified:    locks/unix thread_rwlock.c
  Log:
  To produce results which are defined by POSIX, at time of cleanup the
  rwlock must be initialized but not locked by any thread.  Accordingly,
  remove code which POSIX says gives undefined results:
  
  * locks/unix/thread_rwlock.c (thread_rwlock_cleanup): Don't unlock an
  unlocked lock.  (apr_thread_rwlock_create): Don't destroy an
  uninitialized lock if _init fails.  (apr_thread_rwlock_destroy): If
  cleanup fails, the lock must be in a bad state, so don't run cleanup
  again.
  
  Revision  Changes    Path
  1.9       +4 -7      apr/locks/unix/thread_rwlock.c
  
  Index: thread_rwlock.c
  ===================================================================
  RCS file: /home/cvs/apr/locks/unix/thread_rwlock.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -u -r1.8 -r1.9
  --- thread_rwlock.c	6 Jan 2003 23:44:31 -0000	1.8
  +++ thread_rwlock.c	3 Oct 2003 15:14:38 -0000	1.9
  @@ -59,12 +59,13 @@
   
   #ifdef HAVE_PTHREAD_RWLOCK_INIT
   
  +/* The rwlock must be initialized but not locked by any thread when
  + * cleanup is called. */
   static apr_status_t thread_rwlock_cleanup(void *data)
   {
       apr_thread_rwlock_t *rwlock = (apr_thread_rwlock_t *)data;
       apr_status_t stat;
   
  -    pthread_rwlock_unlock(rwlock->rwlock);
       stat = pthread_rwlock_destroy(rwlock->rwlock);
   #ifdef PTHREAD_SETS_ERRNO
       if (stat) {
  @@ -99,7 +100,6 @@
   #ifdef PTHREAD_SETS_ERRNO
           stat = errno;
   #endif
  -        thread_rwlock_cleanup(new_rwlock);
           return stat;
       }
   
  @@ -184,11 +184,8 @@
   
   APR_DECLARE(apr_status_t) apr_thread_rwlock_destroy(apr_thread_rwlock_t *rwlock)
   {
  -    apr_status_t stat;
  -    if ((stat = thread_rwlock_cleanup(rwlock)) == APR_SUCCESS) {
  -        apr_pool_cleanup_kill(rwlock->pool, rwlock, thread_rwlock_cleanup);
  -        return APR_SUCCESS;
  -    }
  +    apr_status_t stat = thread_rwlock_cleanup(rwlock);
  +    apr_pool_cleanup_kill(rwlock->pool, rwlock, thread_rwlock_cleanup);
       return stat;
   }
   
  
  
  

Mime
View raw message