[Patch] Fix gethwnd race

Christopher Faylor cgf-no-personal-reply-please@cygwin.com
Fri May 14 04:24:00 GMT 2004


On Thu, May 13, 2004 at 04:21:48PM -0500, Brian Ford wrote:
>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 you had said: "I was trying to avoid having a persisent muto for what
is basically a one-time use" that would have made a lot more sense to me.

What you said was: "I can't use a muto because a muto would have to be
acquired and released by the same thread".

There is nothing in this message that I can see which supports this claim.
When someone makes a claim like this, I immediately think that they do not
understand the actual problem and, so, do not devote a lot of time into
looking at any proposed solution.

I'm sure you understand this since you frequently say that you have
little time to work on cygwin.  Given that nearly everyone who donates
time to work on free software is similarly constrained, it should not
be surprising that eventually we develop short cuts for making sure that
any time we spend is spent effectively.

Looking for little clues of "not getting it" is usually a good way of
figuring out how much time to spend on an issue.

I can see the merits in trying to avoid an additional handle but I don't
think inventing a mutex-like structure just for use in windows.cc merits
that much effort.  It's difficult for me, looking at your code, to
verify that you have achieved thread safety.  It's a lot easier for me,
writing standard code, with a standard cygwin control structure, to
verify thread safety.

However, I'll look at your code again with my new understanding of your
intent.

cgf



More information about the Cygwin-patches mailing list