apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject cvs commit: apr-util/misc apr_reslist.c
Date Wed, 10 Dec 2003 18:20:22 GMT
trawick     2003/12/10 10:20:22

  Modified:    .        CHANGES
               include  apr_reslist.h
               misc     apr_reslist.c
  Log:
  Add timeout feature to apr_reslist_acquire().
  
  Submitted by:   Mladen Turk <mturk apache.org>
  Reviewed by:	Jeff Trawick
  
  Revision  Changes    Path
  1.122     +3 -0      apr-util/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr-util/CHANGES,v
  retrieving revision 1.121
  retrieving revision 1.122
  diff -u -r1.121 -r1.122
  --- CHANGES	6 Dec 2003 01:29:43 -0000	1.121
  +++ CHANGES	10 Dec 2003 18:20:21 -0000	1.122
  @@ -1,5 +1,8 @@
   Changes with APR-util 1.0
   
  +  *) Add timeout feature to apr_reslist_acquire().  
  +     [Mladen Turk <mturk apache.org>]
  +
     *) Fixed a bug in apr_rmm that would cause it to mishandle blocks of
        a size close to the one requested from the allocator.
        [Kevin Wang <xwang_tech yahoo.com>]
  
  
  
  1.6       +9 -0      apr-util/include/apr_reslist.h
  
  Index: apr_reslist.h
  ===================================================================
  RCS file: /home/cvs/apr-util/include/apr_reslist.h,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- apr_reslist.h	1 Jan 2003 00:02:20 -0000	1.5
  +++ apr_reslist.h	10 Dec 2003 18:20:21 -0000	1.6
  @@ -150,6 +150,15 @@
   APU_DECLARE(apr_status_t) apr_reslist_release(apr_reslist_t *reslist,
                                                 void *resource);
   
  +/**
  + * Set the timeout the acquire will wait for a free resource
  + * when the maximum number of resources is exceeded.
  + * @param reslist The resource list.
  + * @param timeout Timeout to wait. The zero waits forewer.
  + */
  +APU_DECLARE(void) apr_reslist_timeout_set(apr_reslist_t *reslist,
  +                                          apr_interval_time_t timeout);
  +
   #ifdef __cplusplus
   }
   #endif
  
  
  
  1.7       +16 -1     apr-util/misc/apr_reslist.c
  
  Index: apr_reslist.c
  ===================================================================
  RCS file: /home/cvs/apr-util/misc/apr_reslist.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- apr_reslist.c	6 Oct 2003 20:34:30 -0000	1.6
  +++ apr_reslist.c	10 Dec 2003 18:20:22 -0000	1.7
  @@ -88,6 +88,7 @@
       int smax; /* soft maximum on the total number of resources */
       int hmax; /* hard maximum on the total number of resources */
       apr_interval_time_t ttl; /* TTL when we have too many resources */
  +    apr_interval_time_t timeout; /* Timeout for waiting on resource */
       apr_reslist_constructor constructor;
       apr_reslist_destructor destructor;
       void *params; /* opaque data passed to constructor and destructor calls */
  @@ -343,7 +344,15 @@
        * a new one, or something becomes free. */
       else while (reslist->ntotal >= reslist->hmax
                   && reslist->nidle <= 0) {
  -        apr_thread_cond_wait(reslist->avail, reslist->listlock);
  +        if (reslist->timeout) {
  +            if ((rv = apr_thread_cond_timedwait(reslist->avail, 
  +                reslist->listlock, reslist->timeout)) != APR_SUCCESS) {
  +                apr_thread_mutex_unlock(reslist->listlock);
  +                return rv;
  +            }
  +        }
  +        else
  +            apr_thread_cond_wait(reslist->avail, reslist->listlock);
       }
       /* If we popped out of the loop, first try to see if there
        * are new resources available for immediate use. */
  @@ -382,6 +391,12 @@
       apr_thread_mutex_unlock(reslist->listlock);
   
       return reslist_maint(reslist);
  +}
  +
  +APU_DECLARE(void) apr_reslist_timeout_set(apr_reslist_t *reslist,
  +                                          apr_interval_time_t timeout)
  +{
  +    reslist->timeout = timeout;
   }
   
   #endif  /* APR_HAS_THREADS */
  
  
  

Mime
View raw message