From dev-return-14274-apmail-apr-dev-archive=apr.apache.org@apr.apache.org Tue May 31 20:39:21 2005 Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 75945 invoked from network); 31 May 2005 20:39:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 31 May 2005 20:39:21 -0000 Received: (qmail 50217 invoked by uid 500); 31 May 2005 20:39:19 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 50133 invoked by uid 500); 31 May 2005 20:39:18 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Id: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 50118 invoked by uid 99); 31 May 2005 20:39:18 -0000 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=FORGED_RCVD_HELO X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from rwcrmhc14.comcast.net (HELO rwcrmhc14.comcast.net) (216.148.227.89) by apache.org (qpsmtpd/0.28) with ESMTP; Tue, 31 May 2005 13:39:17 -0700 Received: from localhost.localdomain (c-24-6-11-151.hsd1.ca.comcast.net[24.6.11.151]) by comcast.net (rwcrmhc14) with ESMTP id <20050531203915014001i6kle>; Tue, 31 May 2005 20:39:15 +0000 Received: from [192.168.123.1] (helo=localhost) by localhost.localdomain with esmtp (Exim 4.50) id 1DdDW6-0005vF-HB for dev@apr.apache.org; Tue, 31 May 2005 13:39:14 -0700 Subject: Missing WaitForSingleObject on apr_thread_cont's mutex? From: Henry Jen To: dev@apr.apache.org Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-MYN9mtvpRF+SEwgQS4T4" Date: Tue, 31 May 2005 13:38:35 -0700 Message-Id: <1117571915.5587.14.camel@hammerhead.sfbay.sun.com> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --=-MYN9mtvpRF+SEwgQS4T4 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, I was looking at the apr_thread_cond.c, and wondering if the apr_thread_cond_wait & apr_thread_cond_timedwait code is missing a WaitForSingleObject call on the mutex. Would someone share some light with me? :-)=20 The following is code snippet from the SVN trunk, and it seems to be same as in apr-0.9.6. Comments in the code. Cheers, --=20 Henry Jen aka slowhog http://blogs.sun.com/slowhog APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond, apr_thread_mutex_t *mutex) { DWORD res; while (1) { res =3D WaitForSingleObject(cond->mutex, INFINITE); if (res !=3D WAIT_OBJECT_0) { return apr_get_os_error(); } cond->num_waiting++; /* cond->mutec had been released here */ ReleaseMutex(cond->mutex); apr_thread_mutex_unlock(mutex); res =3D WaitForSingleObject(cond->event, INFINITE); /* should we add a mutex lock here to protect num_waiting value? */ /* WaitForSingleObject(cond->mutex, INFINITE); */ cond->num_waiting--; if (res !=3D WAIT_OBJECT_0) { apr_status_t rv =3D apr_get_os_error(); /* Aren't we releasing a mutex without locking it first? */ ReleaseMutex(cond->mutex); return rv; } if (cond->signal_all) { if (cond->num_waiting =3D=3D 0) { ResetEvent(cond->event); } break; } if (cond->signalled) { cond->signalled =3D 0; ResetEvent(cond->event); break; } /* Aren't we releasing a mutex without locking it first? */ ReleaseMutex(cond->mutex); } apr_thread_mutex_lock(mutex); return APR_SUCCESS; } --=-MYN9mtvpRF+SEwgQS4T4 Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQBCnMtKLNaoAyBG0PURAqINAJ91aNX02THQDeFeQoSVYhT9ZXwJogCeLOMo UI2DvKQvqezT6AgmQZgYoqo= =f9tg -----END PGP SIGNATURE----- --=-MYN9mtvpRF+SEwgQS4T4--