* 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.
This commit is contained in:
Christopher Faylor 2012-04-28 19:49:58 +00:00
parent 2875f31af2
commit ea17849f8b
5 changed files with 31 additions and 11 deletions

View File

@ -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.

View File

@ -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}}},

View File

@ -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;

View File

@ -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)

View File

@ -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);