diff options
author | Ken Brown <kbrown@cornell.edu> | 2019-05-09 10:58:29 -0400 |
---|---|---|
committer | Ken Brown <kbrown@cornell.edu> | 2019-05-09 14:41:29 -0400 |
commit | f3d1fe2ff81ad6f5327caa9229626e39101da2c9 (patch) | |
tree | f26e0d019a41e91708852e3baa593ae57e522216 | |
parent | 1372021a2dc380946f9d8b549315975205132413 (diff) | |
download | cygnal-f3d1fe2ff81ad6f5327caa9229626e39101da2c9.tar.gz cygnal-f3d1fe2ff81ad6f5327caa9229626e39101da2c9.tar.bz2 cygnal-f3d1fe2ff81ad6f5327caa9229626e39101da2c9.zip |
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.
-rw-r--r-- | winsup/cygwin/fhandler.h | 1 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_fifo.cc | 23 |
2 files changed, 15 insertions, 9 deletions
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index f5ed61cc4..3b2b194e8 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -1279,6 +1279,7 @@ class fhandler_fifo: public fhandler_base void delete_client_handler (int); bool listen_client (); int stop_listen_client (); + void record_connection (fifo_client_handler&); public: fhandler_fifo (); bool hit_eof (); diff --git a/winsup/cygwin/fhandler_fifo.cc b/winsup/cygwin/fhandler_fifo.cc index dd59eb6e0..8dfe49662 100644 --- a/winsup/cygwin/fhandler_fifo.cc +++ b/winsup/cygwin/fhandler_fifo.cc @@ -300,6 +300,19 @@ fhandler_fifo::listen_client () 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 fhandler_fifo::listen_client_thread () { @@ -363,19 +376,11 @@ fhandler_fifo::listen_client_thread () break; } } - HANDLE evt = NULL; switch (status) { case STATUS_SUCCESS: case STATUS_PIPE_CONNECTED: - fifo_client_lock (); - 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 (); + record_connection (fc); break; case STATUS_PIPE_LISTENING: /* Retry. */ |