Cygwin: FIFO: remove fifo_client_handler::connect_evt
It's not needed. Instead just create and use an event in fhandler_fifo::listen_client_thread.
This commit is contained in:
parent
5b2696cb83
commit
6e7e82fee7
|
@ -1253,8 +1253,7 @@ struct fifo_client_handler
|
||||||
{
|
{
|
||||||
fhandler_base *fh;
|
fhandler_base *fh;
|
||||||
fifo_client_connect_state state;
|
fifo_client_connect_state state;
|
||||||
HANDLE connect_evt;
|
fifo_client_handler () : fh (NULL), state (fc_unknown) {}
|
||||||
fifo_client_handler () : fh (NULL), state (fc_unknown), connect_evt (NULL) {}
|
|
||||||
int close ();
|
int close ();
|
||||||
/* Returns FILE_PIPE_DISCONNECTED_STATE, FILE_PIPE_LISTENING_STATE,
|
/* Returns FILE_PIPE_DISCONNECTED_STATE, FILE_PIPE_LISTENING_STATE,
|
||||||
FILE_PIPE_CONNECTED_STATE, FILE_PIPE_CLOSING_STATE,
|
FILE_PIPE_CONNECTED_STATE, FILE_PIPE_CLOSING_STATE,
|
||||||
|
|
|
@ -231,8 +231,6 @@ fhandler_fifo::add_client_handler ()
|
||||||
set_errno (EMFILE);
|
set_errno (EMFILE);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (!(fc.connect_evt = create_event ()))
|
|
||||||
goto out;
|
|
||||||
if (!(fh = build_fh_dev (dev ())))
|
if (!(fh = build_fh_dev (dev ())))
|
||||||
{
|
{
|
||||||
set_errno (EMFILE);
|
set_errno (EMFILE);
|
||||||
|
@ -304,15 +302,16 @@ fhandler_fifo::record_connection (fifo_client_handler& fc)
|
||||||
nconnected++;
|
nconnected++;
|
||||||
fc.fh->set_nonblocking (true);
|
fc.fh->set_nonblocking (true);
|
||||||
set_pipe_non_blocking (fc.fh->get_handle (), true);
|
set_pipe_non_blocking (fc.fh->get_handle (), true);
|
||||||
HANDLE evt = InterlockedExchangePointer (&fc.connect_evt, NULL);
|
|
||||||
if (evt)
|
|
||||||
CloseHandle (evt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD
|
DWORD
|
||||||
fhandler_fifo::listen_client_thread ()
|
fhandler_fifo::listen_client_thread ()
|
||||||
{
|
{
|
||||||
DWORD ret = -1;
|
DWORD ret = -1;
|
||||||
|
HANDLE evt;
|
||||||
|
|
||||||
|
if (!(evt = create_event ()))
|
||||||
|
goto out;
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -353,12 +352,11 @@ fhandler_fifo::listen_client_thread ()
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
IO_STATUS_BLOCK io;
|
IO_STATUS_BLOCK io;
|
||||||
|
|
||||||
status = NtFsControlFile (fc.fh->get_handle (), fc.connect_evt,
|
status = NtFsControlFile (fc.fh->get_handle (), evt, NULL, NULL, &io,
|
||||||
NULL, NULL, &io, FSCTL_PIPE_LISTEN,
|
FSCTL_PIPE_LISTEN, NULL, 0, NULL, 0);
|
||||||
NULL, 0, NULL, 0);
|
|
||||||
if (status == STATUS_PENDING)
|
if (status == STATUS_PENDING)
|
||||||
{
|
{
|
||||||
HANDLE w[2] = { fc.connect_evt, lct_termination_evt };
|
HANDLE w[2] = { evt, lct_termination_evt };
|
||||||
DWORD waitret = WaitForMultipleObjects (2, w, false, INFINITE);
|
DWORD waitret = WaitForMultipleObjects (2, w, false, INFINITE);
|
||||||
switch (waitret)
|
switch (waitret)
|
||||||
{
|
{
|
||||||
|
@ -384,6 +382,7 @@ fhandler_fifo::listen_client_thread ()
|
||||||
case STATUS_SUCCESS:
|
case STATUS_SUCCESS:
|
||||||
case STATUS_PIPE_CONNECTED:
|
case STATUS_PIPE_CONNECTED:
|
||||||
record_connection (fc);
|
record_connection (fc);
|
||||||
|
ResetEvent (evt);
|
||||||
break;
|
break;
|
||||||
case STATUS_THREAD_IS_TERMINATING:
|
case STATUS_THREAD_IS_TERMINATING:
|
||||||
/* Force NtFsControlFile to complete. Otherwise the next
|
/* Force NtFsControlFile to complete. Otherwise the next
|
||||||
|
@ -431,9 +430,13 @@ fhandler_fifo::listen_client_thread ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
if (ret < 0)
|
if (evt)
|
||||||
debug_printf ("exiting lct with error, %E");
|
CloseHandle (evt);
|
||||||
ResetEvent (read_ready);
|
ResetEvent (read_ready);
|
||||||
|
if (ret < 0)
|
||||||
|
debug_printf ("exiting with error, %E");
|
||||||
|
else
|
||||||
|
debug_printf ("exiting without error");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -908,10 +911,7 @@ int
|
||||||
fifo_client_handler::close ()
|
fifo_client_handler::close ()
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
HANDLE evt = InterlockedExchangePointer (&connect_evt, NULL);
|
|
||||||
|
|
||||||
if (evt)
|
|
||||||
CloseHandle (evt);
|
|
||||||
if (fh)
|
if (fh)
|
||||||
{
|
{
|
||||||
res = fh->fhandler_base::close ();
|
res = fh->fhandler_base::close ();
|
||||||
|
|
Loading…
Reference in New Issue