summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2012-04-28 19:49:58 +0000
committerChristopher Faylor <me@cgf.cx>2012-04-28 19:49:58 +0000
commitea17849f8b0f2280f259ad24fd5e8891864f4cf6 (patch)
tree2edaaf1feaa4dff84a4babd342a71535f2221d71
parent2875f31af2aa5fd1adac8a43d823f20125289c6c (diff)
downloadcygnal-ea17849f8b0f2280f259ad24fd5e8891864f4cf6.tar.gz
cygnal-ea17849f8b0f2280f259ad24fd5e8891864f4cf6.tar.bz2
cygnal-ea17849f8b0f2280f259ad24fd5e8891864f4cf6.zip
* environ.cc (struct parse_thing): Add temporary (?) "pipe_byte" option.
* globals.cc (pipe_byte): Declare. * pipe.cc (fhandler_pipe::create): Use current process id in pipe name rather than pid for simple name collision avoidance. Do this only once to avoid extra overhead when a busy pipe is found. Honor pipe_byte to create non-message pipes if set. * sigproc.cc (sigproc_init): Use a specific name for the signal pipe.
-rw-r--r--winsup/cygwin/ChangeLog12
-rw-r--r--winsup/cygwin/environ.cc1
-rw-r--r--winsup/cygwin/globals.cc1
-rw-r--r--winsup/cygwin/pipe.cc26
-rw-r--r--winsup/cygwin/sigproc.cc2
5 files changed, 31 insertions, 11 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index c8186e4e7..02f77d7b0 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,13 @@
+2012-04-28 Christopher Faylor <me.cygwin2012@cgf.cx>
+
+ * environ.cc (struct parse_thing): Add temporary (?) "pipe_byte" option.
+ * globals.cc (pipe_byte): Declare.
+ * pipe.cc (fhandler_pipe::create): Use current process id in pipe name
+ rather than pid for simple name collision avoidance. Do this only once
+ to avoid extra overhead when a busy pipe is found. Honor pipe_byte to
+ create non-message pipes if set.
+ * sigproc.cc (sigproc_init): Use a specific name for the signal pipe.
+
2012-04-27 Corinna Vinschen <corinna@vinschen.de>
* path.cc (find_fast_cwd_pointer): Fix for W8 CP 32 bit.
@@ -1291,7 +1301,7 @@
* fhandler.h (fhandler_fifo::arm): Declare new function.
* fhandler_fifo.cc (fhandler_fifo::arm): Define new function.
(fhandler_fifo::open): Fix handling of RDWR pipes to avoid opening a
- second handle. Use arm() function to set events.
+ second handle. Use arm() function to set events.
(fhandler_fifo::raw_read): Correctly go into "connect again logic" when
we detect another writer is available. Use arm() function to set event.
* pipe.cc (fhandler_pipe::create): Add more detail to debugging output.
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index 33289d2f5..ae3944a6c 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -117,6 +117,7 @@ static struct parse_thing
{"error_start", {func: error_start_init}, isfunc, NULL, {{0}, {0}}},
{"export", {&export_settings}, setbool, NULL, {{false}, {true}}},
{"glob", {func: glob_init}, isfunc, NULL, {{0}, {s: "normal"}}},
+ {"pipe_byte", {&pipe_byte}, setbool, NULL, {{false}, {true}}},
{"proc_retry", {func: set_proc_retry}, isfunc, NULL, {{0}, {5}}},
{"reset_com", {&reset_com}, setbool, NULL, {{false}, {true}}},
{"tty", {func: tty_is_gone}, isfunc, NULL, {{0}, {0}}},
diff --git a/winsup/cygwin/globals.cc b/winsup/cygwin/globals.cc
index 87b6cd84e..9bce8f395 100644
--- a/winsup/cygwin/globals.cc
+++ b/winsup/cygwin/globals.cc
@@ -58,6 +58,7 @@ bool ignore_case_with_glob = false;
bool dos_file_warning = true;
bool allow_winsymlinks = false;
bool reset_com = false;
+bool pipe_byte = false;
bool detect_bloda = false;
bool NO_COPY in_forkee;
diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc
index 52f2ba058..e8d15915f 100644
--- a/winsup/cygwin/pipe.cc
+++ b/winsup/cygwin/pipe.cc
@@ -211,10 +211,17 @@ fhandler_pipe::create (LPSECURITY_ATTRIBUTES sa_ptr, PHANDLE r, PHANDLE w,
psize = DEFAULT_PIPEBUFSIZE;
char pipename[MAX_PATH];
- const size_t len = __small_sprintf (pipename, PIPE_INTRO "%S-",
- &cygheap->installation_key);
- if (name)
- strcpy (pipename + len, name);
+ const size_t len = __small_sprintf (pipename, PIPE_INTRO "%S-%u-",
+ &cygheap->installation_key,
+ GetCurrentProcessId ());
+ DWORD pipe_mode = PIPE_READMODE_BYTE;
+ if (!name)
+ pipe_mode |= pipe_byte ? PIPE_TYPE_BYTE : PIPE_TYPE_MESSAGE;
+ else
+ {
+ strcpy (pipename + len, name);
+ pipe_mode |= PIPE_TYPE_MESSAGE;
+ }
open_mode |= PIPE_ACCESS_INBOUND;
@@ -226,10 +233,12 @@ fhandler_pipe::create (LPSECURITY_ATTRIBUTES sa_ptr, PHANDLE r, PHANDLE w,
{
static volatile ULONG pipe_unique_id;
if (!name)
- __small_sprintf (pipename + len, "pipe-%p-%p", myself->pid,
- InterlockedIncrement ((LONG *) &pipe_unique_id));
+ __small_sprintf (pipename + len, "pipe-%p",
+ InterlockedIncrement ((LONG *) &pipe_unique_id));
- debug_printf ("CreateNamedPipe: name %s, size %lu", pipename, psize);
+ debug_printf ("name %s, size %lu, mode %s", pipename, psize,
+ (pipe_mode & PIPE_TYPE_MESSAGE)
+ ? "PIPE_TYPE_MESSAGE" : "PIPE_TYPE_BYTE");
/* Use CreateNamedPipe instead of CreatePipe, because the latter
returns a write handle that does not permit FILE_READ_ATTRIBUTES
@@ -246,8 +255,7 @@ fhandler_pipe::create (LPSECURITY_ATTRIBUTES sa_ptr, PHANDLE r, PHANDLE w,
definitely required for pty handling since fhandler_pty_master
writes to the pipe in chunks, terminated by newline when CANON mode
is specified. */
- *r = CreateNamedPipe (pipename, open_mode,
- PIPE_TYPE_MESSAGE | PIPE_READMODE_BYTE, 1, psize,
+ *r = CreateNamedPipe (pipename, open_mode, pipe_mode, 1, psize,
psize, NMPWAIT_USE_DEFAULT_WAIT, sa_ptr);
if (*r != INVALID_HANDLE_VALUE)
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index a8a85ebb6..93fc75b11 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -529,7 +529,7 @@ sigproc_init ()
char char_sa_buf[1024];
PSECURITY_ATTRIBUTES sa = sec_user_nih ((PSECURITY_ATTRIBUTES) char_sa_buf, cygheap->user.sid());
DWORD err = fhandler_pipe::create (sa, &my_readsig, &my_sendsig,
- sizeof (sigpacket), NULL, 0);
+ sizeof (sigpacket), "sigwait", 0);
if (err)
{
SetLastError (err);