apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dr...@apache.org
Subject cvs commit: apr/threadproc/unix thread.c
Date Wed, 06 Jun 2001 18:12:17 GMT
dreid       01/06/06 11:12:17

  Modified:    .        acconfig.h
               include  apr.h.in apr_lock.h apr_portable.h apr_sms.h
                        apr_thread_proc.h
               include/arch/beos locks.h
               include/arch/os2 locks.h
               include/arch/unix locks.h
               include/arch/win32 locks.h
               memory/unix apr_sms_std.c apr_sms_tracking.c
               locks/beos crossproc.c locks.c
               locks/unix crossproc.c locks.c
               locks/win32 locks.c
               threadproc/beos thread.c
               threadproc/unix thread.c
  Log:
  This is a much larger commit than I meant to have, but a lot has
  been changed in my tree today :)
  
  - remove the sms code I committed yesterday
  - add an apr_pool_t to the sms structure
  - add locking code to the tracking sms
  
  This threw up an issue with locking, so next
  
  - change the locking code to add an owner and ref counting
    so we can lock multiple times from the same thread.  this was
    needed by the apr_sms_tracking_reset code where we lock
    and then call free which locks again...
  
  I haven't added the locking changes for os2 or win32 after
  the problems I created with my last commit :)
  
  Changes to testlock on the way.
  
  Revision  Changes    Path
  1.45      +0 -42     apr/acconfig.h
  
  Index: acconfig.h
  ===================================================================
  RCS file: /home/cvs/apr/acconfig.h,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- acconfig.h	2001/06/05 13:21:52	1.44
  +++ acconfig.h	2001/06/06 18:10:55	1.45
  @@ -67,46 +67,4 @@
   #define apr_sigwait(a,b) sigwait((a),(b))
   #endif
   
  -/* Macros to deal with using either a pool or an sms
  - * to do memory stuff...
  - */
  -#define APR_CLEANUP_REGISTER(struct, data, func, scope) \
  -    if (struct->pool) { \
  -        apr_pool_cleanup_register(struct->pool, data, func, scope); \
  -    } else { \
  -        apr_sms_cleanup_register(struct->mem_sys, APR_CHILD_CLEANUP, \
  -                                 data, func); \
  -    }
  -
  -#define APR_CLEANUP_REMOVE(struct, data, func) \
  -    if (struct->pool) { \
  -        apr_pool_cleanup_kill(struct->pool, data, func); \
  -    } else { \
  -        apr_sms_cleanup_unregister(struct->mem_sys, APR_CHILD_CLEANUP, \
  -                                   data, func); \
  -    }
  -
  -#define APR_MEM_PSTRDUP(struct, ptr, str) \
  -    if (struct->pool) { \
  -        ptr = apr_pstrdup(struct->pool, str); \
  -    } else { \
  -        size_t len = strlen(str) + 1; \
  -        ptr = (char*) apr_sms_calloc(struct->mem_sys, len); \
  -        memcpy(ptr, str, len); \
  -    }
  -
  -#define APR_MEM_MALLOC(ptr, struct, type) \
  -    if (struct->pool) { \
  -        ptr = (type *)apr_palloc(struct->pool, sizeof(type)); \
  -    } else { \
  -        ptr = (type *)apr_sms_malloc(struct->mem_sys, sizeof(type)); \
  -    }
  -
  -#define APR_MEM_CALLOC(ptr, struct, type) \
  -    if (struct->pool) { \
  -        ptr = (type *)apr_pcalloc(struct->pool, sizeof(type)); \
  -    } else { \
  -        ptr = (type *)apr_sms_calloc(struct->mem_sys, sizeof(type)); \
  -    }
  -
   #endif /* APR_PRIVATE_H */
  
  
  
  1.82      +0 -3      apr/include/apr.h.in
  
  Index: apr.h.in
  ===================================================================
  RCS file: /home/cvs/apr/include/apr.h.in,v
  retrieving revision 1.81
  retrieving revision 1.82
  diff -u -r1.81 -r1.82
  --- apr.h.in	2001/06/05 08:15:05	1.81
  +++ apr.h.in	2001/06/06 18:11:01	1.82
  @@ -174,9 +174,6 @@
   typedef  @off_t_value@           apr_off_t;
   typedef  @socklen_t_value@       apr_socklen_t;
   
  -typedef struct apr_lock_t        apr_lock_t;
  -typedef struct apr_sms_t         apr_sms_t;
  -
   /* Mechanisms to properly type numeric literals */
   @int64_literal@
   
  
  
  
  1.27      +2 -1      apr/include/apr_lock.h
  
  Index: apr_lock.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_lock.h,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- apr_lock.h	2001/06/05 13:21:59	1.26
  +++ apr_lock.h	2001/06/06 18:11:02	1.27
  @@ -58,7 +58,6 @@
   #include "apr.h"
   #include "apr_pools.h"
   #include "apr_errno.h"
  -#include "apr_sms.h"
   
   #ifdef __cplusplus
   extern "C" {
  @@ -73,6 +72,8 @@
   typedef enum {APR_MUTEX, APR_READWRITE} apr_locktype_e;
   
   typedef enum {APR_READER, APR_WRITER} apr_readerwriter_e;
  +
  +typedef struct apr_lock_t    apr_lock_t;
   
   /*   Function definitions */
   
  
  
  
  1.55      +2 -0      apr/include/apr_portable.h
  
  Index: apr_portable.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_portable.h,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- apr_portable.h	2001/05/23 12:27:29	1.54
  +++ apr_portable.h	2001/06/06 18:11:04	1.55
  @@ -418,6 +418,8 @@
   APR_DECLARE(apr_status_t) apr_os_dso_handle_get(apr_os_dso_handle_t *dso,
                                                   apr_dso_handle_t *aprdso);
   
  +APR_DECLARE(apr_os_thread_t) apr_os_thread_current(void);
  +
   #endif /* APR_HAS_DSO */
   
   #ifdef __cplusplus
  
  
  
  1.11      +25 -20    apr/include/apr_sms.h
  
  Index: apr_sms.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_sms.h,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- apr_sms.h	2001/06/05 09:23:30	1.10
  +++ apr_sms.h	2001/06/06 18:11:05	1.11
  @@ -65,6 +65,8 @@
   
   #include "apr.h"
   #include "apr_errno.h"
  +#include "apr_pools.h"
  +#include "apr_lock.h"
   
   #ifdef __cplusplus
   extern "C" {
  @@ -80,32 +82,35 @@
    */
   
   struct apr_sms_cleanup;
  +typedef struct apr_sms_t    apr_sms_t;
   
   /**
    * The memory system structure
    */
   struct apr_sms_t
   {
  -  apr_sms_t  *parent_mem_sys;
  -  apr_sms_t  *child_mem_sys;
  -  apr_sms_t  *sibling_mem_sys;
  -  apr_sms_t **ref_mem_sys;
  -  apr_sms_t  *accounting_mem_sys;
  -  const char *identity; /* a string identifying the module */
  -  apr_lock_t *lock;
  -
  -  struct apr_sms_cleanup *cleanups;
  -
  -  void * (*malloc_fn)       (apr_sms_t *mem_sys, apr_size_t size);
  -  void * (*calloc_fn)       (apr_sms_t *mem_sys, apr_size_t size);
  -  void * (*realloc_fn)      (apr_sms_t *mem_sys, void *memory, 
  -                             apr_size_t size);
  -  apr_status_t (*free_fn)   (apr_sms_t *mem_sys, void *memory);
  -  apr_status_t (*reset_fn)  (apr_sms_t *mem_sys);
  -  void (*pre_destroy_fn)    (apr_sms_t *mem_sys);
  -  apr_status_t (*destroy_fn)(apr_sms_t *mem_sys);
  -  apr_status_t (*lock_fn)   (apr_sms_t *mem_sys);
  -  apr_status_t (*unlock_fn) (apr_sms_t *mem_sys);
  +    apr_sms_t  *parent_mem_sys;
  +    apr_sms_t  *child_mem_sys;
  +    apr_sms_t  *sibling_mem_sys;
  +    apr_sms_t **ref_mem_sys;
  +    apr_sms_t  *accounting_mem_sys;
  +    const char *identity; /* a string identifying the module */
  +
  +    apr_pool_t *pool;
  +    apr_lock_t *lock;
  +
  +    struct apr_sms_cleanup *cleanups;
  +
  +    void * (*malloc_fn)       (apr_sms_t *mem_sys, apr_size_t size);
  +    void * (*calloc_fn)       (apr_sms_t *mem_sys, apr_size_t size);
  +    void * (*realloc_fn)      (apr_sms_t *mem_sys, void *memory, 
  +                               apr_size_t size);
  +    apr_status_t (*free_fn)   (apr_sms_t *mem_sys, void *memory);
  +    apr_status_t (*reset_fn)  (apr_sms_t *mem_sys);
  +    void (*pre_destroy_fn)    (apr_sms_t *mem_sys);
  +    apr_status_t (*destroy_fn)(apr_sms_t *mem_sys);
  +    apr_status_t (*lock_fn)   (apr_sms_t *mem_sys);
  +    apr_status_t (*unlock_fn) (apr_sms_t *mem_sys);
   };
   
   /*
  
  
  
  1.65      +1 -0      apr/include/apr_thread_proc.h
  
  Index: apr_thread_proc.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_thread_proc.h,v
  retrieving revision 1.64
  retrieving revision 1.65
  diff -u -r1.64 -r1.65
  --- apr_thread_proc.h	2001/05/16 20:55:49	1.64
  +++ apr_thread_proc.h	2001/06/06 18:11:06	1.65
  @@ -65,6 +65,7 @@
   #include <sys/resource.h>
   #endif
   
  +
   #ifdef __cplusplus
   extern "C" {
   #endif /* __cplusplus */
  
  
  
  1.15      +2 -6      apr/include/arch/beos/locks.h
  
  Index: locks.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/beos/locks.h,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- locks.h	2001/06/05 13:22:06	1.14
  +++ locks.h	2001/06/06 18:11:16	1.15
  @@ -60,13 +60,13 @@
   #include "apr_file_io.h"
   #include "apr_general.h"
   #include "apr_lib.h"
  -#include "apr_sms.h"
   
   struct apr_lock_t {
       apr_pool_t *pool;
  -    apr_sms_t *mem_sys;
       apr_locktype_e type;
       apr_lockscope_e scope;
  +    apr_os_thread_t *owner;
  +    int owner_ref;
       /* Inter proc */
       sem_id sem_interproc;
       int32  ben_interproc;
  @@ -87,10 +87,6 @@
   
   apr_status_t child_init_lock(struct apr_lock_t **lock, apr_pool_t *cont, 
                               const char *fname);
  -
  -apr_status_t apr_lock_sms_create(apr_lock_t **lock, apr_locktype_e type,
  -                                 apr_lockscope_e scope, const char *fname,
  -                                 apr_sms_t *mem_sys);
   
   #endif  /* LOCKS_H */
   
  
  
  
  1.14      +0 -6      apr/include/arch/os2/locks.h
  
  Index: locks.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/os2/locks.h,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- locks.h	2001/06/05 13:22:12	1.13
  +++ locks.h	2001/06/06 18:11:22	1.14
  @@ -57,11 +57,9 @@
   
   #include "apr_lock.h"
   #include "apr_file_io.h"
  -#include "apr_sms.h"
   
   struct apr_lock_t {
       apr_pool_t *pool;
  -    apr_sms_t *mem_sys;
       apr_locktype_e type;
       apr_lockscope_e scope;
       char *fname;
  @@ -70,10 +68,6 @@
       int lock_count;
       TIB *tib;
   };
  -
  -apr_status_t apr_lock_sms_create(apr_lock_t **lock, apr_locktype_e type,
  -                                 apr_lockscope_e scope, const char *fname,
  -                                 apr_sms_t *mem_sys);
   
   #endif  /* LOCKS_H */
   
  
  
  
  1.30      +6 -5      apr/include/arch/unix/locks.h
  
  Index: locks.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/unix/locks.h,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- locks.h	2001/06/05 13:22:18	1.29
  +++ locks.h	2001/06/06 18:11:28	1.30
  @@ -61,6 +61,7 @@
   #include "apr_lib.h"
   #include "apr_lock.h"
   #include "apr_sms.h"
  +#include "apr_portable.h"
   
   /* System headers required by Locks library */
   #if APR_HAVE_SYS_TYPES_H
  @@ -110,11 +111,11 @@
   
   struct apr_lock_t {
       apr_pool_t *pool;
  -    apr_sms_t *mem_sys;
       apr_locktype_e type;
       apr_lockscope_e scope;
       int curr_locked;
       char *fname;
  +
   #if APR_USE_SYSVSEM_SERIALIZE
       int interproc;
   #elif APR_USE_FCNTL_SERIALIZE
  @@ -129,6 +130,10 @@
   #if APR_HAS_THREADS
       /* APR doesn't have threads, no sense in having an thread lock mechanism.
        */
  +
  +    apr_os_thread_t owner;
  +    int owner_ref;
  +
   #if APR_USE_PTHREAD_SERIALIZE
       pthread_mutex_t *intraproc;
   #endif
  @@ -156,10 +161,6 @@
   
   apr_status_t apr_unix_child_init_lock(struct apr_lock_t **lock, 
                                         apr_pool_t *cont, const char *fname);
  -
  -apr_status_t apr_lock_sms_create(apr_lock_t **lock, apr_locktype_e type,
  -                                 apr_lockscope_e scope, const char *fname,
  -                                 apr_sms_t *mem_sys);
   
   #endif  /* LOCKS_H */
   
  
  
  
  1.12      +0 -6      apr/include/arch/win32/locks.h
  
  Index: locks.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/win32/locks.h,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- locks.h	2001/06/06 00:07:46	1.11
  +++ locks.h	2001/06/06 18:11:34	1.12
  @@ -56,21 +56,15 @@
   #define LOCKS_H
   
   #include "apr_lock.h"
  -#include "apr_sms.h"
   
   struct apr_lock_t {
       apr_pool_t *pool;
  -    apr_sms_t *mem_sys;
       apr_locktype_e type;
       apr_lockscope_e scope;
       HANDLE mutex;
       CRITICAL_SECTION section;
       char *fname;
   };
  -
  -APR_DECLARE(apr_status_t) apr_lock_sms_create(apr_lock_t **lock, apr_locktype_e type,
  -                                 apr_lockscope_e scope, const char *fname,
  -                                 apr_sms_t *mem_sys);
   
   #endif  /* LOCKS_H */
   
  
  
  
  1.7       +3 -0      apr/memory/unix/apr_sms_std.c
  
  Index: apr_sms_std.c
  ===================================================================
  RCS file: /home/cvs/apr/memory/unix/apr_sms_std.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- apr_sms_std.c	2001/06/04 23:09:34	1.6
  +++ apr_sms_std.c	2001/06/06 18:11:39	1.7
  @@ -127,6 +127,9 @@
       new_mem_sys->free_fn    = apr_sms_std_free;
       new_mem_sys->identity   = module_identity;
   
  +    /* If this fails, what should we do??? */
  +    apr_pool_create(&(new_mem_sys->pool), NULL);
  +     
       /* as we're not a tracking memory module, i.e. we don't keep
        * track of our allocations, we don't have apr_sms_reset or
        * apr_sms_destroy functions.
  
  
  
  1.7       +43 -3     apr/memory/unix/apr_sms_tracking.c
  
  Index: apr_sms_tracking.c
  ===================================================================
  RCS file: /home/cvs/apr/memory/unix/apr_sms_tracking.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- apr_sms_tracking.c	2001/06/04 23:09:34	1.6
  +++ apr_sms_tracking.c	2001/06/06 18:11:41	1.7
  @@ -86,11 +86,23 @@
       apr_track_node_t    *nodes;
   } apr_sms_tracking_t;
   
  +static apr_status_t apr_sms_tracking_lock(apr_sms_t *mem_sys)
  +{
  +    return apr_lock_acquire(mem_sys->lock);
  +}
  +
  +static apr_status_t apr_sms_tracking_unlock(apr_sms_t *mem_sys)
  +{
  +    return apr_lock_release(mem_sys->lock);
  +}
  +
   static void *apr_sms_tracking_malloc(apr_sms_t *mem_sys,
                                        apr_size_t size)
   {
       apr_sms_tracking_t *tms;
       apr_track_node_t *node;
  +
  +    apr_sms_tracking_lock(mem_sys);
     
       tms = (apr_sms_tracking_t *)mem_sys;
       node = apr_sms_malloc(mem_sys->parent_mem_sys,
  @@ -106,6 +118,8 @@
   
       node++;
   
  +    apr_sms_tracking_unlock(mem_sys);
  +
       return (void *)node;
   }
   
  @@ -115,6 +129,8 @@
       apr_sms_tracking_t *tms;
       apr_track_node_t *node;
     
  +    apr_sms_tracking_lock(mem_sys);
  +
       tms = (apr_sms_tracking_t *)mem_sys;
       node = apr_sms_calloc(mem_sys->parent_mem_sys,
                             size + sizeof(apr_track_node_t));
  @@ -129,6 +145,8 @@
   
       node++;
   
  +    apr_sms_tracking_unlock(mem_sys);
  +
       return (void *)node;
   }
   
  @@ -138,6 +156,8 @@
       apr_sms_tracking_t *tms;
       apr_track_node_t *node;
   
  +    apr_sms_tracking_lock(mem_sys);
  +
       tms = (apr_sms_tracking_t *)mem_sys;
       node = (apr_track_node_t *)mem;
   
  @@ -159,6 +179,8 @@
   
       node++;
   
  +    apr_sms_tracking_unlock(mem_sys);
  +
       return (void *)node;
   }
   
  @@ -166,14 +188,18 @@
                                             void *mem)
   {
       apr_track_node_t *node;
  -    
  + 
  +    apr_sms_tracking_lock(mem_sys);
  +   
       node = (apr_track_node_t *)mem;
       node--;
   
       *(node->ref) = node->next;
       if (node->next)
           node->next->ref = node->ref;
  -          
  + 
  +    apr_sms_tracking_unlock(mem_sys);
  +         
       return apr_sms_free(mem_sys->parent_mem_sys, node);
   }
   
  @@ -182,6 +208,9 @@
       apr_sms_tracking_t *tms;
       apr_track_node_t *node;
       apr_status_t rv;
  +
  +    if ((rv = apr_sms_tracking_lock(mem_sys)) != APR_SUCCESS)
  +        return rv;
    
       tms = (apr_sms_tracking_t *)mem_sys;
   
  @@ -191,10 +220,15 @@
           if (node->next)
               node->next->ref = node->ref;
           if ((rv = apr_sms_free(mem_sys->parent_mem_sys, 
  -                               node)) != APR_SUCCESS)
  +                               node)) != APR_SUCCESS) {
  +            apr_sms_tracking_unlock(mem_sys);
               return rv;
  +        }
       }
       
  +    if ((rv = apr_sms_tracking_unlock(mem_sys)) != APR_SUCCESS)
  +        return rv;
  +
       return APR_SUCCESS;
   }
   
  @@ -233,8 +267,14 @@
       new_mem_sys->realloc_fn = apr_sms_tracking_realloc;
       new_mem_sys->free_fn    = apr_sms_tracking_free;
       new_mem_sys->reset_fn   = apr_sms_tracking_reset;
  +    new_mem_sys->lock_fn    = apr_sms_tracking_lock;
  +    new_mem_sys->unlock_fn  = apr_sms_tracking_unlock;
       new_mem_sys->destroy_fn = apr_sms_tracking_destroy;
       new_mem_sys->identity   = module_identity;
  +
  +    apr_pool_create(&(new_mem_sys->pool), pms->pool);
  +    apr_lock_create(&(new_mem_sys->lock), APR_MUTEX, APR_LOCKALL, NULL,
  +                    new_mem_sys->pool);
   
       tms = (apr_sms_tracking_t *)new_mem_sys;
       tms->nodes = NULL;
  
  
  
  1.23      +3 -3      apr/locks/beos/crossproc.c
  
  Index: crossproc.c
  ===================================================================
  RCS file: /home/cvs/apr/locks/beos/crossproc.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- crossproc.c	2001/06/05 13:22:27	1.22
  +++ crossproc.c	2001/06/06 18:11:46	1.23
  @@ -82,8 +82,8 @@
       }
       new->ben_interproc = 0;
       new->sem_interproc = stat;
  -    APR_CLEANUP_REGISTER(new, (void *)new, lock_inter_cleanup,
  -                        apr_pool_cleanup_null);
  +    apr_pool_cleanup_register(new->pool, (void *)new, lock_inter_cleanup,
  +                              apr_pool_cleanup_null);
       return APR_SUCCESS;
   }
   
  @@ -117,7 +117,7 @@
   {
       apr_status_t stat;
       if ((stat = lock_inter_cleanup(lock)) == APR_SUCCESS) {
  -        APR_CLEANUP_REMOVE(lock, lock, lock_inter_cleanup);
  +        apr_pool_cleanup_kill(lock->pool, lock, lock_inter_cleanup);
           return APR_SUCCESS;
       }
       return stat;
  
  
  
  1.30      +17 -34    apr/locks/beos/locks.c
  
  Index: locks.c
  ===================================================================
  RCS file: /home/cvs/apr/locks/beos/locks.c,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- locks.c	2001/06/05 13:22:30	1.29
  +++ locks.c	2001/06/06 18:11:48	1.30
  @@ -90,44 +90,15 @@
       return APR_SUCCESS;
   }
   
  -apr_status_t apr_lock_sms_create(apr_lock_t **lock, apr_locktype_e type, 
  -                                 apr_lockscope_e scope, const char *fname, 
  -                                 apr_sms_t *mem_sys)
  -{
  -    apr_lock_t *new;
  -    apr_status_t stat;
  -  
  -    /* FIXME: Remove when read write locks implemented. */ 
  -    if (type == APR_READWRITE)
  -        return APR_ENOTIMPL; 
  -
  -    new = (apr_lock_t *)apr_sms_calloc(mem_sys, sizeof(apr_lock_t));
  -    if (new == NULL){
  -        return APR_ENOMEM;
  -    }
  -    
  -    new->mem_sys = mem_sys;
  -    new->type    = type;
  -    new->scope   = scope;
  -
  -    if (scope != APR_CROSS_PROCESS) {
  -        if ((stat = create_intra_lock(new)) != APR_SUCCESS) {
  -            return stat;
  -        }
  -    }
  -    if (scope != APR_INTRAPROCESS) {
  -        if ((stat = create_inter_lock(new)) != APR_SUCCESS) {
  -            return stat;
  -        }
  -    }
  -    (*lock) = new;
  -    return APR_SUCCESS;
  -}
  -
   apr_status_t apr_lock_acquire(apr_lock_t *lock)
   {
       apr_status_t stat;
   
  +    if (lock->owner == apr_os_thread_current()) {
  +        lock->owner_ref++;
  +        return APR_SUCCESS;
  +    }
  +
       switch (lock->type)
       {
       case APR_MUTEX:
  @@ -146,6 +117,9 @@
           return APR_ENOTIMPL;
       }
   
  +    lock->owner = apr_os_thread_current();
  +    lock->owner_ref = 1;
  +
       return APR_SUCCESS;
   }
   
  @@ -173,6 +147,12 @@
   {
       apr_status_t stat;
   
  +    if (lock->owner == apr_os_thread_current()) {
  +        lock->owner_ref--;
  +        if (lock->owner_ref > 0)
  +            return APR_SUCCESS;
  +    }
  +
       switch (lock->type)
       {
       case APR_MUTEX:
  @@ -190,6 +170,9 @@
       case APR_READWRITE:
           return APR_ENOTIMPL;
       }
  +
  +    lock->owner = -1;
  +    lock->owner_ref = 0;
   
       return APR_SUCCESS;
   }
  
  
  
  1.45      +14 -10    apr/locks/unix/crossproc.c
  
  Index: crossproc.c
  ===================================================================
  RCS file: /home/cvs/apr/locks/unix/crossproc.c,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- crossproc.c	2001/06/05 13:22:42	1.44
  +++ crossproc.c	2001/06/06 18:11:55	1.45
  @@ -100,7 +100,8 @@
           return errno;
       }
       new->curr_locked = 0;
  -    APR_CLEANUP_REGISTER(new, (void *)new, lock_cleanup, apr_pool_cleanup_null);
  +    apr_pool_cleanup_register(new->pool, (void *)new, lock_cleanup, 
  +                              apr_pool_cleanup_null);
       return APR_SUCCESS;
   }
   
  @@ -137,7 +138,7 @@
       apr_status_t stat;
   
       if ((stat = lock_cleanup(lock)) == APR_SUCCESS) {
  -        APR_CLEANUP_REMOVE(lock, lock, lock_cleanup);
  +        apr_pool_cleanup_kill(lock->pool, lock, lock_cleanup);
           return APR_SUCCESS;
       }
       return stat;
  @@ -223,7 +224,8 @@
       }
   
       new->curr_locked = 0;
  -    APR_CLEANUP_REGISTER(new, (void *)new, lock_cleanup, apr_pool_cleanup_null);
  +    apr_pool_register_cleanup(new->pool, (void *)new, lock_cleanup, 
  +                              apr_pool_cleanup_null);
       return APR_SUCCESS;
   }
   
  @@ -259,7 +261,7 @@
   {
       apr_status_t stat;
       if ((stat = lock_cleanup(lock)) == APR_SUCCESS) {
  -        APR_CLEANUP_REMOVE(lock, lock, lock_cleanup);
  +        apr_pool_cleanup_kill(lock->pool, lock, lock_cleanup);
           return APR_SUCCESS;
       }
       return stat;
  @@ -305,7 +307,7 @@
           new->interproc = open(new->fname, O_CREAT | O_WRONLY | O_EXCL, 0644);
       }
       else {
  -        APR_MEM_PSTRDUP(new, new->fname, "/tmp/aprXXXXXX")
  +        new->fname = apr_pstrdup(new->pool, "/tmp/aprXXXXXX");
           new->interproc = apr_mkstemp(new->fname);
       }
   
  @@ -316,7 +318,8 @@
   
       new->curr_locked=0;
       unlink(new->fname);
  -    APR_CLEANUP_REGISTER(new, new, lock_cleanup, apr_pool_cleanup_null);
  +    apr_pool_cleanup_register(new->pool, (void*)new, lock_cleanup, 
  +                              apr_pool_cleanup_null);
       return APR_SUCCESS; 
   }
   
  @@ -352,7 +355,7 @@
   {
       apr_status_t stat;
       if ((stat = lock_cleanup(lock)) == APR_SUCCESS) {
  -        APR_CLEANUP_REMOVE(lock, lock, lock_cleanup);
  +        apr_pool_cleanup_kill(lock->pool, lock, lock_cleanup);
           return APR_SUCCESS;
       }
       return stat;
  @@ -388,7 +391,7 @@
           new->interproc = open(new->fname, O_CREAT | O_WRONLY | O_EXCL, 0600);
       }
       else {
  -        APR_MEM_PSTRDUP(new, new->fname, "/tmp/aprXXXXXX")
  +        new->fname = apr_pstrdup(new->pool, "/tmp/aprXXXXXX");
           new->interproc = apr_mkstemp(new->fname);
       }
   
  @@ -397,7 +400,8 @@
           return errno;
       }
       new->curr_locked = 0;
  -    APR_CLEANUP_REGISTER(new, (void *)new, lock_cleanup, apr_pool_cleanup_null);
  +    apr_pool_cleanup_register(new->pool, (void *)new, lock_cleanup,
  +                              apr_pool_cleanup_null);
       return APR_SUCCESS;
   }
   
  @@ -433,7 +437,7 @@
   {
       apr_status_t stat;
       if ((stat = lock_cleanup(lock)) == APR_SUCCESS) {
  -        APR_CLEANUP_REMOVE(lock, lock, lock_cleanup);
  +        apr_pool_cleanup_kill(lock->new, lock, lock_cleanup);
           return APR_SUCCESS;
       }
       return stat;
  
  
  
  1.51      +26 -21    apr/locks/unix/locks.c
  
  Index: locks.c
  ===================================================================
  RCS file: /home/cvs/apr/locks/unix/locks.c,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- locks.c	2001/06/05 13:48:25	1.50
  +++ locks.c	2001/06/06 18:11:59	1.51
  @@ -67,7 +67,7 @@
       /* file-based serialization primitives */
       if (new->scope != APR_INTRAPROCESS) {
           if (fname != NULL) {
  -            APR_MEM_PSTRDUP(new, new->fname, fname);
  +            new->fname = apr_pstrdup(new->pool, fname);
           }
       }
   #endif
  @@ -126,30 +126,17 @@
       return APR_SUCCESS;
   }
   
  -apr_status_t apr_lock_sms_create(apr_lock_t **lock, apr_locktype_e type,
  -                                 apr_lockscope_e scope, const char *fname,
  -                                 apr_sms_t *mem_sys)
  -{
  -    apr_lock_t *new;
  -    apr_status_t stat;
  -    
  -    new = (apr_lock_t *)apr_sms_calloc(mem_sys, sizeof(apr_lock_t));
  -
  -    new->mem_sys = mem_sys;
  -    new->type    = type;
  -    new->scope   = scope;
  -
  -    if ((stat = create_lock(new, fname)) != APR_SUCCESS)
  -        return stat;
  -
  -    *lock = new;
  -    return APR_SUCCESS;
  -}
  -
   apr_status_t apr_lock_acquire(apr_lock_t *lock)
   {
       apr_status_t stat;
   
  +#if APR_HAS_THREADS
  +    if (lock->owner == apr_os_thread_current()){
  +        lock->owner_ref++;
  +        return APR_SUCCESS;
  +    }
  +#endif
  +
       switch (lock->type)
       {
       case APR_MUTEX:
  @@ -176,6 +163,11 @@
           return APR_ENOTIMPL;
       }
   
  +#if APR_HAS_THREADS
  +    lock->owner = apr_os_thread_current();
  +    lock->owner_ref = 1;
  +#endif
  +
       return APR_SUCCESS;
   }
   
  @@ -211,6 +203,14 @@
   {
       apr_status_t stat;
   
  +#if APR_HAS_THREADS
  +    if (lock->owner == apr_os_thread_current()) {
  +        lock->owner_ref--;
  +        if (lock->owner_ref > 0)
  +            return APR_SUCCESS;
  +    }
  +#endif
  +
       switch (lock->type)
       {
       case APR_MUTEX:
  @@ -242,6 +242,11 @@
           return APR_ENOTIMPL;
   #endif
       }
  +
  +#if APR_HAS_THREADS
  +    lock->owner = NULL;
  +    lock->owner_ref = 0;
  +#endif
       
       return APR_SUCCESS;
   }
  
  
  
  1.43      +0 -39     apr/locks/win32/locks.c
  
  Index: locks.c
  ===================================================================
  RCS file: /home/cvs/apr/locks/win32/locks.c,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- locks.c	2001/06/06 03:57:47	1.42
  +++ locks.c	2001/06/06 18:12:04	1.43
  @@ -100,45 +100,6 @@
       return APR_SUCCESS;
   }
   
  -APR_DECLARE(apr_status_t) apr_lock_sms_create(apr_lock_t **lock,
  -                                              apr_locktype_e type,
  -                                              apr_lockscope_e scope,
  -                                              const char *fname,
  -                                              apr_sms_t *mem_sys)
  -{
  -    apr_lock_t *newlock;
  -    SECURITY_ATTRIBUTES sec;
  -
  -    if (type == APR_READWRITE)
  -        return APR_ENOTIMPL;
  -
  -    newlock = (apr_lock_t *)apr_sms_malloc(mem_sys, sizeof(apr_lock_t));
  -
  -    newlock->pool = NULL;
  -    newlock->mem_sys = mem_sys;
  -
  -    APR_MEM_PSTRDUP(newlock, newlock->fname, fname);
  -    newlock->type = type;
  -    newlock->scope = scope;
  -    sec.nLength = sizeof(SECURITY_ATTRIBUTES);
  -    sec.lpSecurityDescriptor = NULL;
  -
  -    if (scope == APR_CROSS_PROCESS || scope == APR_LOCKALL) {
  -        sec.bInheritHandle = TRUE;
  -    }
  -    else {
  -        sec.bInheritHandle = FALSE;
  -    }
  -
  -    if (scope == APR_INTRAPROCESS) {
  -        InitializeCriticalSection(&newlock->section);
  -    } else {
  -        newlock->mutex = CreateMutex(&sec, FALSE, fname);
  -    }
  -    *lock = newlock;
  -    return APR_SUCCESS;
  -}
  -
   APR_DECLARE(apr_status_t) apr_lock_child_init(apr_lock_t **lock, 
                                                 const char *fname, 
                                                 apr_pool_t *pool)
  
  
  
  1.21      +6 -0      apr/threadproc/beos/thread.c
  
  Index: thread.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/beos/thread.c,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- thread.c	2001/04/11 02:01:19	1.20
  +++ thread.c	2001/06/06 18:12:08	1.21
  @@ -53,6 +53,7 @@
    */
   
   #include "threadproc.h"
  +#include "apr_portable.h"
   
   apr_status_t apr_threadattr_create(apr_threadattr_t **new, apr_pool_t *cont)
   {
  @@ -120,6 +121,11 @@
       else {
           return errno;
       } 
  +}
  +
  +apr_os_thread_t apr_os_thread_current(void)
  +{
  +    return find_thread(NULL);
   }
   
   apr_status_t apr_thread_exit(apr_thread_t *thd, apr_status_t *retval)
  
  
  
  1.38      +5 -0      apr/threadproc/unix/thread.c
  
  Index: thread.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/unix/thread.c,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- thread.c	2001/04/11 02:01:22	1.37
  +++ thread.c	2001/06/06 18:12:14	1.38
  @@ -158,6 +158,11 @@
       } 
   }
   
  +apr_os_thread_t apr_os_thread_current(void)
  +{
  +    return pthread_self();
  +}
  +
   apr_status_t apr_thread_exit(apr_thread_t *thd, apr_status_t *retval)
   {
       apr_pool_destroy(thd->cntxt);
  
  
  

Mime
View raw message