You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by st...@apache.org on 2001/07/03 15:58:54 UTC

cvs commit: apr/memory/unix apr_sms.c apr_sms_std.c apr_sms_trivial.c apr_sms_tracking.c

striker     01/07/03 06:58:53

  Modified:    include  apr_sms.h
               memory/unix apr_sms.c apr_sms_std.c apr_sms_trivial.c
                        apr_sms_tracking.c
  Log:
  Second pass at implementing dynamic locking in the sms code.
  
  Revision  Changes    Path
  1.28      +0 -3      apr/include/apr_sms.h
  
  Index: apr_sms.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_sms.h,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- apr_sms.h	2001/07/03 11:07:01	1.27
  +++ apr_sms.h	2001/07/03 13:58:32	1.28
  @@ -67,10 +67,7 @@
   #include "apr_errno.h"
   #include "apr_pools.h"
   #include "apr_lock.h"
  -
  -#if APR_HAS_THREADS
   #include "apr_portable.h"
  -#endif /* APR_HAS_THREADS */
   
   #ifdef __cplusplus
   extern "C" {
  
  
  
  1.37      +11 -0     apr/memory/unix/apr_sms.c
  
  Index: apr_sms.c
  ===================================================================
  RCS file: /home/cvs/apr/memory/unix/apr_sms.c,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- apr_sms.c	2001/07/03 12:44:50	1.36
  +++ apr_sms.c	2001/07/03 13:58:39	1.37
  @@ -842,6 +842,8 @@
   APR_DECLARE(apr_status_t) apr_sms_thread_register(apr_sms_t *sms,
                                                     apr_os_thread_t thread)
   {
  +    apr_status_t rv;
  +    
       do {
           if (!sms->sms_lock) {
               /* Create the sms framework lock we'll use. */
  @@ -856,11 +858,20 @@
           /* let the sms know about the thread if it is
            * interested (so it can protect its private
            * data with its own lock)
  +         *
  +         * if the sms is doesn't have a thread register
  +         * function, or it wasn't able to register the
  +         * thread, we should bomb out!
  +         * XXX - not sure how to implement the bombing out
            */
  +        rv = APR_ENOTIMPL;
           if (sms->thread_register_fn)
               sms->thread_register_fn(sms, thread);
   
           apr_lock_release(sms->sms_lock);
  +
  +        if (rv != APR_SUCCESS)
  +            return rv;
   
           sms = sms->parent;
       } while (sms);
  
  
  
  1.13      +23 -5     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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- apr_sms_std.c	2001/07/02 08:13:01	1.12
  +++ apr_sms_std.c	2001/07/03 13:58:40	1.13
  @@ -105,6 +105,20 @@
       return APR_SUCCESS;
   }
   
  +#if APR_HAS_THREADS
  +static apr_status_t apr_sms_std_thread_register(apr_sms_t *sms,
  +                                                apr_os_thread_t thread)
  +{
  +    return APR_SUCCESS;
  +}
  +
  +static apr_status_t apr_sms_std_thread_unregister(apr_sms_t *sms,
  +                                                  apr_os_thread_t thread)
  +{
  +    return APR_SUCCESS;
  +}
  +#endif /* APR_HAS_THREADS */
  +
   APR_DECLARE(apr_status_t) apr_sms_std_create(apr_sms_t **sms)
   {
       apr_sms_t *new_sms;
  @@ -122,11 +136,15 @@
       if ((rv = apr_sms_init(new_sms, NULL)) != APR_SUCCESS)
           return rv;
   
  -    new_sms->malloc_fn  = apr_sms_std_malloc;
  -    new_sms->calloc_fn  = apr_sms_std_calloc;
  -    new_sms->realloc_fn = apr_sms_std_realloc;
  -    new_sms->free_fn    = apr_sms_std_free;
  -    new_sms->identity   = module_identity;
  +    new_sms->malloc_fn            = apr_sms_std_malloc;
  +    new_sms->calloc_fn            = apr_sms_std_calloc;
  +    new_sms->realloc_fn           = apr_sms_std_realloc;
  +    new_sms->free_fn              = apr_sms_std_free;
  +#if APR_HAS_THREADS
  +    new_sms->thread_register_fn   = apr_sms_std_thread_register;
  +    new_sms->thread_unregister_fn = apr_sms_std_thread_unregister;
  +#endif /* APR_HAS_THREADS */
  +    new_sms->identity             = module_identity;
   
       /* 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
  
  
  
  1.9       +2 -4      apr/memory/unix/apr_sms_trivial.c
  
  Index: apr_sms_trivial.c
  ===================================================================
  RCS file: /home/cvs/apr/memory/unix/apr_sms_trivial.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- apr_sms_trivial.c	2001/07/03 12:55:26	1.8
  +++ apr_sms_trivial.c	2001/07/03 13:58:42	1.9
  @@ -388,8 +388,7 @@
   }
   
   #if APR_HAS_THREADS
  -static apr_status_t apr_sms_trivial_thread_register(
  -                                                    apr_sms_t *sms,
  +static apr_status_t apr_sms_trivial_thread_register(apr_sms_t *sms,
                                                       apr_os_thread_t thread)
   {
       if (!SMS_TRIVIAL_T(sms)->lock && sms->threads > 1)
  @@ -400,8 +399,7 @@
       return APR_SUCCESS;
   }
   
  -static apr_status_t apr_sms_trivial_thread_unregister(
  -                                                      apr_sms_t *sms,
  +static apr_status_t apr_sms_trivial_thread_unregister(apr_sms_t *sms,
                                                         apr_os_thread_t thread)
   {
       return APR_SUCCESS;
  
  
  
  1.19      +32 -8     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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- apr_sms_tracking.c	2001/07/02 08:13:02	1.18
  +++ apr_sms_tracking.c	2001/07/03 13:58:43	1.19
  @@ -89,6 +89,8 @@
       apr_lock_t          *lock;
   } apr_sms_tracking_t;
   
  +#define SMS_TRACKING_T(sms)  ((apr_sms_tracking_t *)(sms))
  +
   #define INSERT_NODE(node, tms) \
       if (tms->lock) \
           apr_lock_acquire(tms->lock); \
  @@ -256,6 +258,24 @@
       return apr_sms_free(sms->parent, sms);
   }
   
  +#if APR_HAS_THREADS
  +static apr_status_t apr_sms_tracking_thread_register(apr_sms_t *sms,
  +                                                     apr_os_thread_t thread)
  +{
  +    if (!SMS_TRACKING_T(sms)->lock && sms->threads > 1)
  +        return apr_lock_create(&SMS_TRACKING_T(sms)->lock,
  +                               APR_MUTEX, APR_LOCKALL,
  +                               NULL, sms->pool);
  +    return APR_SUCCESS;
  +}
  +
  +static apr_status_t apr_sms_tracking_thread_unregister(apr_sms_t *sms,
  +                                                       apr_os_thread_t thread)
  +{
  +    return APR_SUCCESS;
  +}
  +#endif /* APR_HAS_THREADS */
  +
   
   APR_DECLARE(apr_status_t) apr_sms_tracking_create(apr_sms_t **sms, 
                                                     apr_sms_t *pms)
  @@ -277,14 +297,18 @@
       if ((rv = apr_sms_init(new_sms, pms)) != APR_SUCCESS)
           return rv;
   
  -    new_sms->malloc_fn      = apr_sms_tracking_malloc;
  -    new_sms->calloc_fn      = apr_sms_tracking_calloc;
  -    new_sms->realloc_fn     = apr_sms_tracking_realloc;
  -    new_sms->free_fn        = apr_sms_tracking_free;
  -    new_sms->reset_fn       = apr_sms_tracking_reset;
  -    new_sms->pre_destroy_fn = apr_sms_tracking_pre_destroy;
  -    new_sms->destroy_fn     = apr_sms_tracking_destroy;
  -    new_sms->identity       = module_identity;
  +    new_sms->malloc_fn            = apr_sms_tracking_malloc;
  +    new_sms->calloc_fn            = apr_sms_tracking_calloc;
  +    new_sms->realloc_fn           = apr_sms_tracking_realloc;
  +    new_sms->free_fn              = apr_sms_tracking_free;
  +    new_sms->reset_fn             = apr_sms_tracking_reset;
  +    new_sms->pre_destroy_fn       = apr_sms_tracking_pre_destroy;
  +    new_sms->destroy_fn           = apr_sms_tracking_destroy;
  +#if APR_HAS_THREADS
  +    new_sms->thread_register_fn   = apr_sms_tracking_thread_register;
  +    new_sms->thread_unregister_fn = apr_sms_tracking_thread_unregister;
  +#endif /* APR_HAS_THREADS */
  +    new_sms->identity             = module_identity;
       
       tms = (apr_sms_tracking_t *)new_sms;
       tms->nodes = NULL;