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 proc_mutex.c
Date Mon, 14 Jun 2004 09:41:05 GMT
jorton      2004/06/14 02:41:04

  Modified:    locks/unix proc_mutex.c
  Log:
  * locks/unix/proc_mutex.c (proc_mutex_proc_pthread_cleanup): Fix
  resource leak: destroy the mutex here, if it was ever initialized.
  (proc_mutex_proc_pthread_create): Destroy the mutexattr object
  on error paths; ensure that _cleanup destroys the mutex on error
  paths iff necessary.
  
  Revision  Changes    Path
  1.44      +18 -1     apr/locks/unix/proc_mutex.c
  
  Index: proc_mutex.c
  ===================================================================
  RCS file: /home/cvs/apr/locks/unix/proc_mutex.c,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -d -w -u -r1.43 -r1.44
  --- proc_mutex.c	14 Jun 2004 09:19:15 -0000	1.43
  +++ proc_mutex.c	14 Jun 2004 09:41:04 -0000	1.44
  @@ -266,6 +266,15 @@
               return rv;
           }
       }
  +    /* curr_locked is set to -1 until the mutex has been created */
  +    if (mutex->curr_locked != -1) {
  +        if ((rv = pthread_mutex_destroy(mutex->pthread_interproc))) {
  +#ifdef PTHREAD_SETS_ERRNO
  +            rv = errno;
  +#endif
  +            return rv;
  +        }
  +    }
       if (munmap((caddr_t)mutex->pthread_interproc, sizeof(pthread_mutex_t))) {
           return errno;
       }
  @@ -294,6 +303,9 @@
           return errno;
       }
       close(fd);
  +
  +    new_mutex->curr_locked = -1; /* until the mutex has been created */
  +
       if ((rv = pthread_mutexattr_init(&mattr))) {
   #ifdef PTHREAD_SETS_ERRNO
           rv = errno;
  @@ -306,6 +318,7 @@
           rv = errno;
   #endif
           proc_mutex_proc_pthread_cleanup(new_mutex);
  +        pthread_mutexattr_destroy(&mattr);
           return rv;
       }
   
  @@ -316,6 +329,7 @@
           rv = errno;
   #endif
           proc_mutex_proc_pthread_cleanup(new_mutex);
  +        pthread_mutexattr_destroy(&mattr);
           return rv;
       }
       if ((rv = pthread_mutexattr_setprotocol(&mattr, PTHREAD_PRIO_INHERIT))) {
  @@ -323,6 +337,7 @@
           rv = errno;
   #endif
           proc_mutex_proc_pthread_cleanup(new_mutex);
  +        pthread_mutexattr_destroy(&mattr);
           return rv;
       }
   #endif
  @@ -332,9 +347,12 @@
           rv = errno;
   #endif
           proc_mutex_proc_pthread_cleanup(new_mutex);
  +        pthread_mutexattr_destroy(&mattr);
           return rv;
       }
   
  +    new_mutex->curr_locked = 0; /* mutex created now */
  +
       if ((rv = pthread_mutexattr_destroy(&mattr))) {
   #ifdef PTHREAD_SETS_ERRNO
           rv = errno;
  @@ -343,7 +361,6 @@
           return rv;
       }
   
  -    new_mutex->curr_locked = 0;
       apr_pool_cleanup_register(new_mutex->pool,
                                 (void *)new_mutex,
                                 apr_proc_mutex_cleanup, 
  
  
  

Mime
View raw message