This is the mail archive of the cygwin-patches 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]

[PATCH 03/14] Cygwin: FIFO: remember the type of the fhandler


Add data members 'reader', 'writer', and 'duplexer' to the
fhandler_fifo class.  Set them in fhandler_fifo::open.  ('duplexer'
replaces the previous '_duplexer'.)

This will be useful in later commits.
---
 winsup/cygwin/fhandler.h       |  2 +-
 winsup/cygwin/fhandler_fifo.cc | 14 ++++----------
 2 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 2898db4df..59d9dad16 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -1272,7 +1272,7 @@ class fhandler_fifo: public fhandler_base
   fifo_client_handler fc_handler[MAX_CLIENTS];
   int nhandlers, nconnected;
   af_unix_spinlock_t _fifo_client_lock;
-  bool _duplexer;
+  bool reader, writer, duplexer;
   bool __reg2 wait (HANDLE);
   NTSTATUS npfs_handle (HANDLE &);
   HANDLE create_pipe_instance (bool);
diff --git a/winsup/cygwin/fhandler_fifo.cc b/winsup/cygwin/fhandler_fifo.cc
index 70551ebac..258c3cf8a 100644
--- a/winsup/cygwin/fhandler_fifo.cc
+++ b/winsup/cygwin/fhandler_fifo.cc
@@ -33,7 +33,7 @@ STATUS_PIPE_EMPTY simply means there's no data to be read. */
 fhandler_fifo::fhandler_fifo ():
   fhandler_base (), read_ready (NULL), write_ready (NULL),
   listen_client_thr (NULL), lct_termination_evt (NULL), nhandlers (0),
-  nconnected (0), _duplexer (false)
+  nconnected (0), reader (false), writer (false), duplexer (false)
 {
   pipe_name_buf[0] = L'\0';
   need_fork_fixup (true);
@@ -224,7 +224,7 @@ fhandler_fifo::create_pipe_instance (bool first)
     }
   access = GENERIC_READ | FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES
     | SYNCHRONIZE;
-  if (first && _duplexer)
+  if (first && duplexer)
     access |= GENERIC_WRITE;
   sharing = FILE_SHARE_READ | FILE_SHARE_WRITE;
   hattr = OBJ_INHERIT;
@@ -421,25 +421,19 @@ fhandler_fifo::open (int flags, mode_t)
    error_errno_set,
    error_set_errno
   } res;
-  bool reader, writer, duplexer;
 
   /* Determine what we're doing with this fhandler: reading, writing, both */
   switch (flags & O_ACCMODE)
     {
     case O_RDONLY:
       reader = true;
-      writer = false;
-      duplexer = false;
       break;
     case O_WRONLY:
       writer = true;
-      reader = false;
-      duplexer = false;
       break;
     case O_RDWR:
       reader = true;
-      writer = false;
-      duplexer = _duplexer = true;
+      duplexer = true;
       break;
     default:
       set_errno (EINVAL);
@@ -769,7 +763,7 @@ fhandler_fifo::raw_read (void *in_ptr, size_t& len)
 		  fifo_client_unlock ();
 		  goto errout;
 		}
-	    else if (nread == 0 && (!_duplexer || i > 0))
+	    else if (nread == 0 && (!duplexer || i > 0))
 	      /* Client has disconnected. */
 	      {
 		fc_handler[i].state = fc_invalid;
-- 
2.17.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]