Return-Path: Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 55636 invoked by uid 500); 1 Sep 2001 07:23:36 -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 55625 invoked from network); 1 Sep 2001 07:23:36 -0000 Content-Type: text/plain; charset="iso-8859-1" From: Ryan Bloom Reply-To: rbb@covalent.net Organization: Covalent Technologies To: "William A. Rowe, Jr." , Subject: Re: cvs commit: apr/threadproc/win32 thread.c Date: Sat, 1 Sep 2001 00:24:28 -0700 X-Mailer: KMail [version 1.3] References: <20010901051023.99649.qmail@icarus.apache.org> <078401c132a9$01b86c90$93c0b0d0@roweclan.net> In-Reply-To: <078401c132a9$01b86c90$93c0b0d0@roweclan.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <20010901072428.A80C546993@koj.rkbloom.net> X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N On Friday 31 August 2001 22:39, William A. Rowe, Jr. wrote: > > rbb 01/08/31 22:10:23 > > > > Modified: include/arch/win32 threadproc.h > > threadproc/win32 thread.c > > Log: > > Implement apr_thread_once for Windows. > > > > +APR_DECLARE(apr_status_t) apr_thread_once(apr_thread_once_t *control, > > + void (*func)(void)) > > +{ > > + InterlockedIncrement(&control->value); > > + if (control->value == 1) { > > + func(); > > + } > > + return APR_SUCCESS; > > +} > > This looks like a possible bug - control->value -could- someday wrap > (especially if it wasn't called once per thread, but once per some > operation!) What if we > > if (control->value) > return APR_SUCCESS; > > first, which will start null, so several folks might > fall in (incrementing to perhaps 2, possibly 10, doubtfully 100). But > everyone hitting that line afterwards gets a fast escape, we're assured it > was done without the kernel call and without the chance for wrapping. We could do that. I don't really like the idea of doing one extra if each time this is called, but it does save a kernel call. Okay, I'll add it right now. :-) Ryan ______________________________________________________________ Ryan Bloom rbb@apache.org Covalent Technologies rbb@covalent.net --------------------------------------------------------------