This is the mail archive of the cygwin-patches@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] Fix gethwnd race


On Thu, May 13, 2004 at 03:28:12PM -0500, Brian Ford wrote:
>On Thu, 13 May 2004, Christopher Faylor wrote:
>
>> >I can't seem to make a muto fit this situation cleanly since it would
>> >have to be acquired and released by the same thread.
>>
>> Why would it be acquired and released from the same thread?
>
>What I was trying to say is that a muto must be acquired and released from
>the same thread.  But here, we want to block all threads calling gethwnd
>until the window thread has initialized.
>
>> Isn't the problem that multiple people are calling gethwnd?
>
>Concurrently, before ourhwnd has been initialized, yes.
>
>> You even mention this in the ChangeLog below.  Given that, the place to
>> put a mutex would seem to be in gethwnd.
>
>It seems to me that you would still need the window_started event then,
>no?  Since a muto contains an event, why use two?  I thought this was
>lighter weight.

Either the hwnd exists or it doesn't.

If it does exist, just return it.  No locking required.

If it doesn't exist, acquire the muto.  Does the hwnd exist now?
If so, release the muto and return the hwnd.

Otherwise, set up hwnd, release the muto and return hwnd.

cgf


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]