summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Brown <kbrown@cornell.edu>2019-05-09 11:36:26 -0400
committerKen Brown <kbrown@cornell.edu>2019-05-09 14:41:29 -0400
commit816c6da53a86edf7f734cab0cd146b6813a220de (patch)
tree4ffccf280e6fd0598073ca57ff1429bc02c2ad05
parent00b2e56d3184231264005d6b1f60b1f40023907b (diff)
downloadcygnal-816c6da53a86edf7f734cab0cd146b6813a220de.tar.gz
cygnal-816c6da53a86edf7f734cab0cd146b6813a220de.tar.bz2
cygnal-816c6da53a86edf7f734cab0cd146b6813a220de.zip
Cygwin: FIFO: add a HANDLE parameter to open_pipe
It's now up to the caller to pass a handle to open_pipe and, if desired, to call set_handle on return. This will be useful for a future commit, in which we will open a client connection without setting an io_handle.
-rw-r--r--winsup/cygwin/fhandler.h2
-rw-r--r--winsup/cygwin/fhandler_fifo.cc16
2 files changed, 9 insertions, 9 deletions
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 16165c42f..683aae15c 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -1270,7 +1270,7 @@ class fhandler_fifo: public fhandler_base
bool __reg2 wait (HANDLE);
NTSTATUS npfs_handle (HANDLE &);
HANDLE create_pipe_instance (bool);
- NTSTATUS open_pipe ();
+ NTSTATUS open_pipe (HANDLE&);
int add_client_handler ();
void delete_client_handler (int);
bool listen_client ();
diff --git a/winsup/cygwin/fhandler_fifo.cc b/winsup/cygwin/fhandler_fifo.cc
index 1a1610998..4d05727cb 100644
--- a/winsup/cygwin/fhandler_fifo.cc
+++ b/winsup/cygwin/fhandler_fifo.cc
@@ -194,9 +194,9 @@ fhandler_fifo::create_pipe_instance (bool first)
return ph;
}
-/* Called when a FIFO is opened for writing. */
+/* Connect to a pipe instance. */
NTSTATUS
-fhandler_fifo::open_pipe ()
+fhandler_fifo::open_pipe (HANDLE& ph)
{
NTSTATUS status;
HANDLE npfsh;
@@ -204,7 +204,6 @@ fhandler_fifo::open_pipe ()
OBJECT_ATTRIBUTES attr;
IO_STATUS_BLOCK io;
ULONG sharing;
- HANDLE ph = NULL;
status = npfs_handle (npfsh);
if (!NT_SUCCESS (status))
@@ -214,8 +213,6 @@ fhandler_fifo::open_pipe ()
npfsh, NULL);
sharing = FILE_SHARE_READ | FILE_SHARE_WRITE;
status = NtOpenFile (&ph, access, &attr, &io, sharing, 0);
- if (NT_SUCCESS (status))
- set_handle (ph);
return status;
}
@@ -472,16 +469,19 @@ fhandler_fifo::open (int flags, mode_t)
/* If we're a duplexer, create the pipe and the first client handler. */
if (duplexer)
{
+ HANDLE ph = NULL;
+
if (add_client_handler () < 0)
{
res = error_errno_set;
goto out;
}
- NTSTATUS status = open_pipe ();
+ NTSTATUS status = open_pipe (ph);
if (NT_SUCCESS (status))
{
record_connection (fc_handler[0]);
- set_pipe_non_blocking (get_handle (), flags & O_NONBLOCK);
+ set_handle (ph);
+ set_pipe_non_blocking (ph, flags & O_NONBLOCK);
}
else
{
@@ -525,7 +525,7 @@ fhandler_fifo::open (int flags, mode_t)
res = error_errno_set;
goto out;
}
- NTSTATUS status = open_pipe ();
+ NTSTATUS status = open_pipe (get_handle ());
if (NT_SUCCESS (status))
{
set_pipe_non_blocking (get_handle (), flags & O_NONBLOCK);