This is the mail archive of the cygwin 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] |
Hi Takashi, On May 21 20:53, Takashi Yano wrote: > [...] > I was looking into this problem, and found the PeekNamedPipe() > call is blocked in fhandler_pty_master::close() when the problem > occurs. > > I had not noticed that, > > https://msdn.microsoft.com/en-us/library/windows/desktop/aa365779(v=vs.85).aspx > > says: > > The PeekNamedPipe function can block thread execution the same > > way any I/O function can when called on a synchronous handle in > > a multi-threaded application. > > I have made a patch attached to resolve this problem. Please have > a look. > > With this patch, NtQueryObject() is used instead of PeekNamedPipe() > to detect closure of the last master handle. > > Please refer to the following discussion for more details. > http://cygwin.com/ml/cygwin/2015-03/msg00221.html > > > ChageLog is as follows. > > 2015-05-21 Takashi Yano <...> > > * fhandler_tty.cc (fhandler_pty_master::close): Use NtQueryObject() > instead of PeekNamedPipe() to detect closing the last master handle. > [...] > + if (output_handle_local) > + { > + OBJECT_BASIC_INFORMATION obi; > + NTSTATUS status; > + ULONG hdl_cnt = 0; > + > + status = NtQueryObject (output_handle_local, ObjectBasicInformation, > + &obi, sizeof obi, NULL); > + if (!NT_SUCCESS (status)) > + debug_printf ("NtQueryObject: %y", status); > + else > + hdl_cnt = obi.HandleCount; > + termios_printf("HandleCount: %d", hdl_cnt); > + if (hdl_cnt == 1) > + SetEvent (input_available_event); > + CloseHandle (output_handle_local); > + } Isn't that racy? Consider two processes doing that at the same time. Both calls to NtQueryObject could come up with hdl_cnt == 2 and the problem persists. Wouldn't it be safer to call SetEvent(input_available_event) all the time from here? Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat
Attachment:
pgp7EFyWcGV6n.pgp
Description: PGP signature
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |