apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject cvs commit: apr/locks/win32 locks.c
Date Wed, 13 Jun 2001 14:41:29 GMT
trawick     01/06/13 07:41:29

  Modified:    .        CHANGES
               locks/win32 locks.c
  Log:
  Clean up Win32 locks when the pool goes away.
  
  Submitted by:       Justin Erenkrantz
  Further mangled by: Jeff Trawick
  
  Revision  Changes    Path
  1.112     +3 -0      apr/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr/CHANGES,v
  retrieving revision 1.111
  retrieving revision 1.112
  diff -u -r1.111 -r1.112
  --- CHANGES	2001/06/10 17:23:00	1.111
  +++ CHANGES	2001/06/13 14:41:23	1.112
  @@ -1,5 +1,8 @@
   Changes with APR b1  
   
  +  *) Clean up Win32 locks when the pool goes away.
  +     [Justin Erenkrantz, Jeff Trawick]
  +
     *) Implement apr_get_home_directory for Win32.  [William Rowe]
   
     *) Complete the implementation of LARGEFILE support on Win32, although
  
  
  
  1.44      +30 -16    apr/locks/win32/locks.c
  
  Index: locks.c
  ===================================================================
  RCS file: /home/cvs/apr/locks/win32/locks.c,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- locks.c	2001/06/06 18:12:04	1.43
  +++ locks.c	2001/06/13 14:41:26	1.44
  @@ -59,6 +59,28 @@
   #include "win32/locks.h"
   #include "apr_portable.h"
   
  +static apr_status_t lock_cleanup(void *lock_)
  +{
  +    apr_lock_t *lock = lock_;
  +
  +    switch (lock->type)
  +    {
  +    case APR_MUTEX:
  +        if (lock->scope == APR_INTRAPROCESS) {
  +            DeleteCriticalSection(&lock->section);
  +            return APR_SUCCESS;
  +        } else {
  +            if (CloseHandle(lock->mutex) == 0) {
  +                return apr_get_os_error();
  +            }
  +        }
  +        break;
  +    case APR_READWRITE:
  +        return APR_ENOTIMPL;
  +    }
  +    return APR_SUCCESS;
  +}
  +
   APR_DECLARE(apr_status_t) apr_lock_create(apr_lock_t **lock, 
                                             apr_locktype_e type, 
                                             apr_lockscope_e scope, 
  @@ -97,6 +119,8 @@
           newlock->mutex = CreateMutex(&sec, FALSE, fname);
       }
       *lock = newlock;
  +    apr_pool_cleanup_register(newlock->pool, newlock, lock_cleanup,
  +                              apr_pool_cleanup_null);
       return APR_SUCCESS;
   }
   
  @@ -189,23 +213,13 @@
   
   APR_DECLARE(apr_status_t) apr_lock_destroy(apr_lock_t *lock)
   {
  -    switch (lock->type)
  -    {
  -    case APR_MUTEX:
  -        if (lock->scope == APR_INTRAPROCESS) {
  -            DeleteCriticalSection(&lock->section);
  -            return APR_SUCCESS;
  -        } else {
  -            if (CloseHandle(lock->mutex) == 0) {
  -                return apr_get_os_error();
  -            }
  -        }
  -        break;
  -    case APR_READWRITE:
  -        return APR_ENOTIMPL;
  -    }
  +    apr_status_t stat;
   
  -    return APR_SUCCESS;
  +    stat = lock_cleanup(lock);
  +    if (stat == APR_SUCCESS) {
  +        apr_pool_cleanup_kill(lock->pool, lock, lock_cleanup);
  +    }
  +    return stat;
   }
   
   APR_DECLARE(apr_status_t) apr_lock_data_get(apr_lock_t *lock, const char *key,
  
  
  

Mime
View raw message