Cygwin: FIFO: add 'record_connection' method
Future commits will have to re-use the code for recording a client connection. For convenience, factor out this code into a new method.
This commit is contained in:
parent
b26fab8cfa
commit
775d8d0242
|
@ -1285,6 +1285,7 @@ class fhandler_fifo: public fhandler_base
|
||||||
void delete_client_handler (int);
|
void delete_client_handler (int);
|
||||||
bool listen_client ();
|
bool listen_client ();
|
||||||
int stop_listen_client ();
|
int stop_listen_client ();
|
||||||
|
void record_connection (fifo_client_handler&);
|
||||||
public:
|
public:
|
||||||
fhandler_fifo ();
|
fhandler_fifo ();
|
||||||
bool hit_eof ();
|
bool hit_eof ();
|
||||||
|
|
|
@ -300,6 +300,19 @@ fhandler_fifo::listen_client ()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
fhandler_fifo::record_connection (fifo_client_handler& fc)
|
||||||
|
{
|
||||||
|
fifo_client_lock ();
|
||||||
|
fc.state = fc_connected;
|
||||||
|
nconnected++;
|
||||||
|
set_pipe_non_blocking (fc.fh->get_handle (), true);
|
||||||
|
fifo_client_unlock ();
|
||||||
|
HANDLE evt = InterlockedExchangePointer (&fc.connect_evt, NULL);
|
||||||
|
if (evt)
|
||||||
|
CloseHandle (evt);
|
||||||
|
}
|
||||||
|
|
||||||
DWORD
|
DWORD
|
||||||
fhandler_fifo::listen_client_thread ()
|
fhandler_fifo::listen_client_thread ()
|
||||||
{
|
{
|
||||||
|
@ -363,19 +376,11 @@ fhandler_fifo::listen_client_thread ()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HANDLE evt = NULL;
|
|
||||||
switch (status)
|
switch (status)
|
||||||
{
|
{
|
||||||
case STATUS_SUCCESS:
|
case STATUS_SUCCESS:
|
||||||
case STATUS_PIPE_CONNECTED:
|
case STATUS_PIPE_CONNECTED:
|
||||||
fifo_client_lock ();
|
record_connection (fc);
|
||||||
fc.state = fc_connected;
|
|
||||||
nconnected++;
|
|
||||||
set_pipe_non_blocking (fc.fh->get_handle (), true);
|
|
||||||
evt = InterlockedExchangePointer (&fc.connect_evt, NULL);
|
|
||||||
if (evt)
|
|
||||||
CloseHandle (evt);
|
|
||||||
fifo_client_unlock ();
|
|
||||||
break;
|
break;
|
||||||
case STATUS_PIPE_LISTENING:
|
case STATUS_PIPE_LISTENING:
|
||||||
/* Retry. */
|
/* Retry. */
|
||||||
|
|
Loading…
Reference in New Issue