Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 12599 invoked from network); 9 Dec 2003 15:45:05 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 9 Dec 2003 15:45:05 -0000 Received: (qmail 92754 invoked by uid 500); 9 Dec 2003 15:45:00 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 92539 invoked by uid 500); 9 Dec 2003 15:44:59 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 92526 invoked from network); 9 Dec 2003 15:44:58 -0000 Message-Id: <200312091544.hB9FiwgP005938@kyle.globalnet.hr> Reply-To: From: "Mladen Turk" To: Subject: [PATCH] Fixed timeout for apr_reslist Date: Tue, 9 Dec 2003 16:44:55 +0100 Organization: Apache Software Foundation MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0085_01C3BE73.C8315AA0" X-Mailer: Microsoft Office Outlook, Build 11.0.5510 In-Reply-To: <3FD5AC73.3080309@attglobal.net> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Thread-Index: AcO+RKRLSgN3Oh71TQaW6RTke6gjaAAI7hqw X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N This is a multi-part message in MIME format. ------=_NextPart_000_0085_01C3BE73.C8315AA0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit > From: Jeff Trawick > > Cliff Woolley wrote: > > > > Is it really correct to return APR_EAGAIN regardless of the return > > value of apr_thread_cond_timedwait()? Or is that a bug caused by a > > lack of {}'s? This is why we tend to say that you should > always use > > {}'s, even if the conditional block is only one line long. > That was the bug. > if not returning whatever apr_thread_cond_timedwait() > returned, why not return APR_TIMEUP instead of APR_EAGAIN? > but like Cliff said I wonder why the retval of > apr_thread_cond_timewait() isn't appropriate? > The fixed patch uses the returning value from apr_thread_cond_timedwait(). Also changed to apr_reslist_timeout_set. MT. ------=_NextPart_000_0085_01C3BE73.C8315AA0 Content-Type: text/plain; name="timedreslist.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="timedreslist.txt" Index: apr_reslist.h=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /home/cvspublic/apr-util/include/apr_reslist.h,v=0A= retrieving revision 1.5=0A= diff -u -r1.5 apr_reslist.h=0A= --- apr_reslist.h 1 Jan 2003 00:02:20 -0000 1.5=0A= +++ apr_reslist.h 9 Dec 2003 15:31:26 -0000=0A= @@ -150,6 +150,15 @@=0A= APU_DECLARE(apr_status_t) apr_reslist_release(apr_reslist_t *reslist,=0A= void *resource);=0A= =0A= +/**=0A= + * Set the timeout the acquire will wait for a free resource=0A= + * when the maximum number of resources is exceeded.=0A= + * @param reslist The resource list.=0A= + * @param timeout Timeout to wait. The zero waits forewer.=0A= + */=0A= +APU_DECLARE(void) apr_reslist_timeout_set(apr_reslist_t *reslist,=0A= + apr_interval_time_t timeout);=0A= +=0A= #ifdef __cplusplus=0A= }=0A= #endif=0A= =0A= Index: apr_reslist.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /home/cvspublic/apr-util/misc/apr_reslist.c,v=0A= retrieving revision 1.6=0A= diff -u -r1.6 apr_reslist.c=0A= --- apr_reslist.c 6 Oct 2003 20:34:30 -0000 1.6=0A= +++ apr_reslist.c 9 Dec 2003 15:33:31 -0000=0A= @@ -88,6 +88,7 @@=0A= int smax; /* soft maximum on the total number of resources */=0A= int hmax; /* hard maximum on the total number of resources */=0A= apr_interval_time_t ttl; /* TTL when we have too many resources */=0A= + apr_interval_time_t timeout; /* Timeout for waiting on resource */=0A= apr_reslist_constructor constructor;=0A= apr_reslist_destructor destructor;=0A= void *params; /* opaque data passed to constructor and destructor = calls */=0A= @@ -343,7 +344,15 @@=0A= * a new one, or something becomes free. */=0A= else while (reslist->ntotal >=3D reslist->hmax=0A= && reslist->nidle <=3D 0) {=0A= - apr_thread_cond_wait(reslist->avail, reslist->listlock);=0A= + if (reslist->timeout) {=0A= + if ((rv =3D apr_thread_cond_timedwait(reslist->avail, =0A= + reslist->listlock, reslist->timeout)) !=3D APR_SUCCESS) = {=0A= + apr_thread_mutex_unlock(reslist->listlock);=0A= + return rv;=0A= + }=0A= + }=0A= + else=0A= + apr_thread_cond_wait(reslist->avail, reslist->listlock);=0A= }=0A= /* If we popped out of the loop, first try to see if there=0A= * are new resources available for immediate use. */=0A= @@ -382,6 +391,12 @@=0A= apr_thread_mutex_unlock(reslist->listlock);=0A= =0A= return reslist_maint(reslist);=0A= +}=0A= +=0A= +APU_DECLARE(void) apr_reslist_timeout_set(apr_reslist_t *reslist,=0A= + apr_interval_time_t timeout)=0A= +{=0A= + reslist->timeout =3D timeout;=0A= }=0A= =0A= #endif /* APR_HAS_THREADS */=0A= ------=_NextPart_000_0085_01C3BE73.C8315AA0--