OSDN Git Service

* fhandler.h (fhandler_pipe::create): Rename from the misnamed
authorcgf <cgf>
Wed, 23 Nov 2011 18:56:56 +0000 (18:56 +0000)
committercgf <cgf>
Wed, 23 Nov 2011 18:56:56 +0000 (18:56 +0000)
"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.

winsup/cygwin/ChangeLog
winsup/cygwin/fhandler.h
winsup/cygwin/fhandler_fifo.cc
winsup/cygwin/fhandler_tty.cc
winsup/cygwin/miscfuncs.cc
winsup/cygwin/pipe.cc
winsup/cygwin/sigproc.cc
winsup/cygwin/tty.cc

index 2c79342..6cc089d 100644 (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
index 4ceba4e..e94a8bf 100644 (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;
 
index 0b1b7b5..a7aecef 100644 (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)
index d8881b2..4b0538f 100644 (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";
index b94f099..414abbf 100644 (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;
index 7bbe96f..60b59ff 100644 (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)
index 8d31139..43b3293 100644 (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
index 095c5b5..829d773 100644 (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