public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Ken Brown <kbrown@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: FIFO: add 'record_connection' method Date: Thu, 09 May 2019 18:52:00 -0000 [thread overview] Message-ID: <20190509185219.101164.qmail@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=f3d1fe2ff81ad6f5327caa9229626e39101da2c9 commit f3d1fe2ff81ad6f5327caa9229626e39101da2c9 Author: Ken Brown <kbrown@cornell.edu> Date: Thu May 9 10:58:29 2019 -0400 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. Diff: --- winsup/cygwin/fhandler.h | 1 + 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 f5ed61c..3b2b194 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 dd59eb6..8dfe496 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. */
reply other threads:[~2019-05-09 18:52 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190509185219.101164.qmail@sourceware.org \ --to=kbrown@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).