This is the mail archive of the
cygwin-patches@cygwin.com
mailing list for the Cygwin project.
Re: [Patch] Fix gethwnd race
On Thu, 13 May 2004, Christopher Faylor wrote:
> Either the hwnd exists or it doesn't.
Ok.
> If it does exist, just return it. No locking required.
Ok, add:
if (ourhwnd)
return ourhwnd;
to the beginning of my patch if your worried about the interlocked
overhead and don't mind a double test.
> If it doesn't exist, acquire the muto.
Ok, but now you have a new persistent object including an event.
> Does the hwnd exist now? If so, release the muto and return the hwnd.
My patch does that without the muto.
> Otherwise, set up hwnd,
by waiting on the other thread with an event? Since you already need that
event, why not use it instead of a muto? You can clean up the event when
your done. The muto stays around until the process exits.
> release the muto and return hwnd.
essentially exactly the same as my patch with one more uncleanable
object/handle.
Yes, I thought of that but it didn't seem as clean. Once again, I don't
care, but I did have a good reason for choosing the method I presented.
(At least, IMHO it was a good reason).
--
Brian Ford
Senior Realtime Software Engineer
VITAL - Visual Simulation Systems
FlightSafety International
the best safety device in any aircraft is a well-trained pilot...