* fhandler.h (fhandler_pipe::create): Rename from the misnamed

"create_selectable".  Change return to DWORD.
(fhandler_pty_common::pipesize): New constant.
* fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Reflect create_selectable
name change.
* miscfuncs.cc (CreatePipeOverlapped): Ditto.
* pipe.cc (fhandler_pipe::create): Ditto.
(fhandler_pipe::create): Rename from the misnamed "create_selectable".  Return
DWORD.  Only set pipe size to default when it is passed in as zero.
* fhandler_tty.cc (fhandler_pty_master::setup): Ditto.  Use
fhandler_pty_common::pipesize rather than a raw constant.
* tty.cc (tty::not_allocated): Ditto.
* sigproc.cc (sigproc_init): Use create_selectable to create the signal pipe to
get a more appropriate message based pipe.
This commit is contained in:
Christopher Faylor 2011-11-23 18:56:57 +00:00
parent cc07096c5c
commit 9f65451e3e
8 changed files with 43 additions and 20 deletions

View File

@ -1,3 +1,22 @@
2011-11-23 Christopher Faylor <me.cygwin2011@cgf.cx>
* fhandler.h (fhandler_pipe::create): Rename from the misnamed
"create_selectable". Change return to DWORD.
(fhandler_pty_common::pipesize): New constant.
* fhandler_fifo.cc (fhandler_fifo::fhandler_fifo): Reflect
create_selectable name change.
* miscfuncs.cc (CreatePipeOverlapped): Ditto.
* pipe.cc (fhandler_pipe::create): Ditto.
(fhandler_pipe::create): Rename from the misnamed "create_selectable".
Return DWORD. Only set pipe size to default when it is passed in as
zero.
* fhandler_tty.cc (fhandler_pty_master::setup): Ditto. Use
fhandler_pty_common::pipesize rather than a raw constant.
* tty.cc (tty::not_allocated): Ditto.
* sigproc.cc (sigproc_init): Use create_selectable to create the signal
pipe to get a more appropriate message based pipe.
2011-11-21 Christopher Faylor <me.cygwin2011@cgf.cx>
* sigproc.cc (remove_proc): Don't do busy loop when exiting since it

View File

@ -690,8 +690,8 @@ public:
int __stdcall ftruncate (_off64_t, bool) __attribute__ ((regparm (3)));
int init (HANDLE, DWORD, mode_t);
static int create (fhandler_pipe *[2], unsigned, int);
static int create_selectable (LPSECURITY_ATTRIBUTES, HANDLE *, HANDLE *, DWORD,
const char *, DWORD);
static DWORD create (LPSECURITY_ATTRIBUTES, HANDLE *, HANDLE *, DWORD,
const char *, DWORD);
fhandler_pipe (void *) {}
void copyto (fhandler_base *x)
@ -1370,6 +1370,7 @@ class fhandler_pty_common: public fhandler_termios
{
pc.file_attributes (FILE_ATTRIBUTE_NORMAL);
}
static const unsigned pipesize = 128 * 1024;
HANDLE output_mutex, input_mutex;
HANDLE input_available_event;

View File

@ -34,7 +34,7 @@ fhandler_fifo::fhandler_fifo ():
#define fnevent(w) fifo_name (npbuf, w "-event")
#define fnpipe() fifo_name (npbuf, "fifo")
#define create_pipe(r, w) \
fhandler_pipe::create_selectable (sa_buf, (r), (w), 0, fnpipe (), open_mode)
fhandler_pipe::create (sa_buf, (r), (w), 0, fnpipe (), open_mode)
char *
fhandler_fifo::fifo_name (char *buf, const char *what)

View File

@ -1630,8 +1630,8 @@ fhandler_pty_master::setup ()
char pipename[sizeof("ptyNNNN-from-master")];
__small_sprintf (pipename, "pty%d-to-master", unit);
res = fhandler_pipe::create_selectable (&sec_none, &get_io_handle (),
&to_master, 128 * 1024, pipename, 0);
res = fhandler_pipe::create (&sec_none, &get_io_handle (), &to_master,
fhandler_pty_common::pipesize, pipename, 0);
if (res)
{
errstr = "output pipe";

View File

@ -337,8 +337,8 @@ nice_to_winprio (int &nice)
BOOL WINAPI
CreatePipeOverlapped (PHANDLE hr, PHANDLE hw, LPSECURITY_ATTRIBUTES sa)
{
int ret = fhandler_pipe::create_selectable (sa, hr, hw, 0, NULL,
FILE_FLAG_OVERLAPPED);
int ret = fhandler_pipe::create (sa, hr, hw, 0, NULL,
FILE_FLAG_OVERLAPPED);
if (ret)
SetLastError (ret);
return ret == 0;

View File

@ -196,9 +196,9 @@ fhandler_pipe::dup (fhandler_base *child, int flags)
which is used to implement select and nonblocking writes.
Note that the return value is either 0 or GetLastError,
unlike CreatePipe, which returns a bool for success or failure. */
int
fhandler_pipe::create_selectable (LPSECURITY_ATTRIBUTES sa_ptr, HANDLE *r,
HANDLE *w, DWORD psize, const char *name, DWORD open_mode)
DWORD
fhandler_pipe::create (LPSECURITY_ATTRIBUTES sa_ptr, PHANDLE r, PHANDLE w,
DWORD psize, const char *name, DWORD open_mode)
{
/* Default to error. */
if (r)
@ -207,7 +207,7 @@ fhandler_pipe::create_selectable (LPSECURITY_ATTRIBUTES sa_ptr, HANDLE *r,
*w = NULL;
/* Ensure that there is enough pipe buffer space for atomic writes. */
if (psize < DEFAULT_PIPEBUFSIZE)
if (!psize)
psize = DEFAULT_PIPEBUFSIZE;
char pipename[MAX_PATH];
@ -327,7 +327,7 @@ fhandler_pipe::create (fhandler_pipe *fhs[2], unsigned psize, int mode)
SECURITY_ATTRIBUTES *sa = sec_none_cloexec (mode);
int res = -1;
int ret = create_selectable (sa, &r, &w, psize, NULL, FILE_FLAG_OVERLAPPED);
int ret = create (sa, &r, &w, psize, NULL, FILE_FLAG_OVERLAPPED);
if (ret)
__seterrno_from_win_error (ret);
else if ((fhs[0] = (fhandler_pipe *) build_fh_dev (*piper_dev)) == NULL)

View File

@ -464,12 +464,14 @@ void __stdcall
sigproc_init ()
{
char char_sa_buf[1024];
PSECURITY_ATTRIBUTES sa_buf = sec_user_nih ((PSECURITY_ATTRIBUTES) char_sa_buf, cygheap->user.sid());
for (int i = 5;
i > 0 && !CreatePipe (&my_readsig, &my_sendsig, sa_buf, 0);
i--)
if (i == 1)
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);
if (err)
{
SetLastError (err);
api_fatal ("couldn't create signal pipe, %E");
}
ProtectHandle (my_readsig);
myself->sendsig = my_sendsig;
/* sync_proc_subproc is used by proc_subproc. It serializes

View File

@ -158,9 +158,10 @@ tty::not_allocated (HANDLE& r, HANDLE& w)
then it exists although we may not have privileges to actually use it. */
char pipename[sizeof("ptyNNNN-from-master")];
__small_sprintf (pipename, "pty%d-from-master", get_unit ());
/* fhandler_pipe::create_selectable returns 0 when creation succeeds */
return fhandler_pipe::create_selectable (&sec_none, &r, &w, 128 * 1024,
pipename, 0) == 0;
/* fhandler_pipe::create returns 0 when creation succeeds */
return fhandler_pipe::create (&sec_none, &r, &w,
fhandler_pty_common::pipesize, pipename,
0) == 0;
}
bool