* fhandler.h (class fhandler_base): Remove uninterruptible_io status
flag. (fhandler_base::ready_for_read): Remove declaration. (fhandler_socket::ready_for_read): Ditto. (fhandler_pipe::ready_for_read): Ditto. (fhandler_tty_master::is_slow): Remove. * fhandler_console.cc (fhandler_console::open): Drop setting uninterruptible_io. * fhandler_serial.cc (fhandler_serial::open): Ditto. * fhandler_tty.cc (fhandler_tty_slave::fhandler_tty_slave): Ditto. (fhandler_tty_master::init_console): Ditto. * pipe.cc (fhandler_pipe::fhandler_pipe): Ditto. (fhandler_pipe::open): Ditto. (_pipe): Ditto. * select.cc (fhandler_pipe::ready_for_read): Remove. (fhandler_base::ready_for_read): Remove. * syscalls.cc (readv): Drop unneeded wait variable. Remove entire test which might lead to calling ready_for_read. Remove now unused label out.
This commit is contained in:
		@@ -1,3 +1,25 @@
 | 
			
		||||
2011-05-04  Corinna Vinschen  <corinna@vinschen.de>
 | 
			
		||||
 | 
			
		||||
	* fhandler.h (class fhandler_base): Remove uninterruptible_io status
 | 
			
		||||
	flag.
 | 
			
		||||
	(fhandler_base::ready_for_read): Remove declaration.
 | 
			
		||||
	(fhandler_socket::ready_for_read): Ditto.
 | 
			
		||||
	(fhandler_pipe::ready_for_read): Ditto.
 | 
			
		||||
	(fhandler_tty_master::is_slow): Remove.
 | 
			
		||||
	* fhandler_console.cc (fhandler_console::open): Drop setting
 | 
			
		||||
	uninterruptible_io.
 | 
			
		||||
	* fhandler_serial.cc (fhandler_serial::open): Ditto.
 | 
			
		||||
	* fhandler_tty.cc (fhandler_tty_slave::fhandler_tty_slave): Ditto.
 | 
			
		||||
	(fhandler_tty_master::init_console): Ditto.
 | 
			
		||||
	* pipe.cc (fhandler_pipe::fhandler_pipe): Ditto.
 | 
			
		||||
	(fhandler_pipe::open): Ditto.
 | 
			
		||||
	(_pipe): Ditto.
 | 
			
		||||
	* select.cc (fhandler_pipe::ready_for_read): Remove.
 | 
			
		||||
	(fhandler_base::ready_for_read): Remove.
 | 
			
		||||
	* syscalls.cc (readv): Drop unneeded wait variable.  Remove entire test
 | 
			
		||||
	which might lead to calling ready_for_read.  Remove now unused label
 | 
			
		||||
	out.
 | 
			
		||||
 | 
			
		||||
2011-05-04  Corinna Vinschen  <corinna@vinschen.de>
 | 
			
		||||
 | 
			
		||||
	* fhandler.h (class fhandler_mailslot): Move down in file and change
 | 
			
		||||
 
 | 
			
		||||
@@ -133,7 +133,6 @@ class fhandler_base
 | 
			
		||||
    unsigned wbinary            : 1; /* binary write mode */
 | 
			
		||||
    unsigned wbinset            : 1; /* binary write mode explicitly set */
 | 
			
		||||
    unsigned nohandle           : 1; /* No handle associated with fhandler. */
 | 
			
		||||
    unsigned uninterruptible_io : 1; /* Set if I/O should be uninterruptible. */
 | 
			
		||||
    unsigned did_lseek          : 1; /* set when lseek is called as a flag that
 | 
			
		||||
					_write should check if we've moved
 | 
			
		||||
					beyond EOF, zero filling or making
 | 
			
		||||
@@ -146,8 +145,8 @@ class fhandler_base
 | 
			
		||||
   public:
 | 
			
		||||
    status_flags () :
 | 
			
		||||
      rbinary (0), rbinset (0), wbinary (0), wbinset (0), nohandle (0),
 | 
			
		||||
      uninterruptible_io (0), did_lseek (0),
 | 
			
		||||
      query_open (no_query), close_on_exec (0), need_fork_fixup (0)
 | 
			
		||||
      did_lseek (0), query_open (no_query), close_on_exec (0),
 | 
			
		||||
      need_fork_fixup (0)
 | 
			
		||||
      {}
 | 
			
		||||
  } status, open_status;
 | 
			
		||||
 | 
			
		||||
@@ -227,7 +226,6 @@ class fhandler_base
 | 
			
		||||
  IMPLEMENT_STATUS_FLAG (bool, wbinset)
 | 
			
		||||
  IMPLEMENT_STATUS_FLAG (bool, rbinset)
 | 
			
		||||
  IMPLEMENT_STATUS_FLAG (bool, nohandle)
 | 
			
		||||
  IMPLEMENT_STATUS_FLAG (bool, uninterruptible_io)
 | 
			
		||||
  IMPLEMENT_STATUS_FLAG (bool, did_lseek)
 | 
			
		||||
  IMPLEMENT_STATUS_FLAG (query_state, query_open)
 | 
			
		||||
  IMPLEMENT_STATUS_FLAG (bool, close_on_exec)
 | 
			
		||||
@@ -375,7 +373,6 @@ public:
 | 
			
		||||
  virtual select_record *select_read (select_stuff *);
 | 
			
		||||
  virtual select_record *select_write (select_stuff *);
 | 
			
		||||
  virtual select_record *select_except (select_stuff *);
 | 
			
		||||
  virtual int ready_for_read (int fd, DWORD howlong);
 | 
			
		||||
  virtual const char *get_native_name ()
 | 
			
		||||
  {
 | 
			
		||||
    return dev ().native;
 | 
			
		||||
@@ -536,7 +533,6 @@ class fhandler_socket: public fhandler_base
 | 
			
		||||
  select_record *select_read (select_stuff *);
 | 
			
		||||
  select_record *select_write (select_stuff *);
 | 
			
		||||
  select_record *select_except (select_stuff *);
 | 
			
		||||
  int ready_for_read (int, DWORD) { return true; }
 | 
			
		||||
  void set_addr_family (int af) {addr_family = af;}
 | 
			
		||||
  int get_addr_family () {return addr_family;}
 | 
			
		||||
  void set_socket_type (int st) { type = st;}
 | 
			
		||||
@@ -615,7 +611,6 @@ public:
 | 
			
		||||
  int __stdcall fstatvfs (struct statvfs *buf) __attribute__ ((regparm (2)));
 | 
			
		||||
  int __stdcall fadvise (_off64_t, _off64_t, int) __attribute__ ((regparm (3)));
 | 
			
		||||
  int __stdcall ftruncate (_off64_t, bool) __attribute__ ((regparm (3)));
 | 
			
		||||
  int ready_for_read (int fd, DWORD howlong);
 | 
			
		||||
  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 * = NULL);
 | 
			
		||||
@@ -1205,7 +1200,6 @@ class fhandler_tty_master: public fhandler_pty_master
 | 
			
		||||
  int init ();
 | 
			
		||||
  int init_console ();
 | 
			
		||||
  void set_winsize (bool);
 | 
			
		||||
  bool is_slow () {return true;}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class fhandler_dev_null: public fhandler_base
 | 
			
		||||
 
 | 
			
		||||
@@ -710,7 +710,6 @@ fhandler_console::open (int flags, mode_t)
 | 
			
		||||
      return 0;
 | 
			
		||||
    }
 | 
			
		||||
  set_io_handle (h);
 | 
			
		||||
  uninterruptible_io (true);	// Handled explicitly in read code
 | 
			
		||||
 | 
			
		||||
  h = CreateFile ("CONOUT$", GENERIC_READ | GENERIC_WRITE,
 | 
			
		||||
		  FILE_SHARE_READ | FILE_SHARE_WRITE, sec_none_cloexec (flags),
 | 
			
		||||
 
 | 
			
		||||
@@ -246,8 +246,6 @@ fhandler_serial::open (int flags, mode_t mode)
 | 
			
		||||
 | 
			
		||||
  SetCommMask (get_handle (), EV_RXCHAR);
 | 
			
		||||
 | 
			
		||||
  uninterruptible_io (true);	// Handled explicitly in read code
 | 
			
		||||
 | 
			
		||||
  overlapped_setup ();
 | 
			
		||||
 | 
			
		||||
  memset (&to, 0, sizeof (to));
 | 
			
		||||
 
 | 
			
		||||
@@ -456,9 +456,7 @@ process_ioctl (void *)
 | 
			
		||||
 | 
			
		||||
fhandler_tty_slave::fhandler_tty_slave ()
 | 
			
		||||
  : fhandler_tty_common (), inuse (NULL)
 | 
			
		||||
{
 | 
			
		||||
  uninterruptible_io (true);
 | 
			
		||||
}
 | 
			
		||||
{}
 | 
			
		||||
 | 
			
		||||
/* FIXME: This function needs to close handles when it has
 | 
			
		||||
   a failing condition. */
 | 
			
		||||
@@ -1652,7 +1650,6 @@ fhandler_tty_master::init_console ()
 | 
			
		||||
 | 
			
		||||
  console->init (NULL, GENERIC_READ | GENERIC_WRITE, O_BINARY);
 | 
			
		||||
  cygheap->manage_console_count ("fhandler_tty_master::init_console", -1, true);
 | 
			
		||||
  console->uninterruptible_io (true);
 | 
			
		||||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -28,7 +28,6 @@ fhandler_pipe::fhandler_pipe ()
 | 
			
		||||
{
 | 
			
		||||
  max_atomic_write = DEFAULT_PIPEBUFSIZE;
 | 
			
		||||
  need_fork_fixup (true);
 | 
			
		||||
  uninterruptible_io (true);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
@@ -130,7 +129,6 @@ fhandler_pipe::open (int flags, mode_t mode)
 | 
			
		||||
      goto out;
 | 
			
		||||
    }
 | 
			
		||||
  init (nio_hdl, fh->get_access (), mode & O_TEXT ?: O_BINARY);
 | 
			
		||||
  uninterruptible_io (fh->uninterruptible_io ());
 | 
			
		||||
  cfree (fh);
 | 
			
		||||
  CloseHandle (proc);
 | 
			
		||||
  return 1;
 | 
			
		||||
@@ -407,7 +405,6 @@ _pipe (int filedes[2], unsigned int psize, int mode)
 | 
			
		||||
    {
 | 
			
		||||
      cygheap_fdnew fdin;
 | 
			
		||||
      cygheap_fdnew fdout (fdin, false);
 | 
			
		||||
      fhs[0]->uninterruptible_io (true);
 | 
			
		||||
      fdin = fhs[0];
 | 
			
		||||
      fdout = fhs[1];
 | 
			
		||||
      filedes[0] = fdin;
 | 
			
		||||
 
 | 
			
		||||
@@ -694,17 +694,6 @@ pipe_cleanup (select_record *, select_stuff *stuff)
 | 
			
		||||
  stuff->device_specific_pipe = NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
fhandler_pipe::ready_for_read (int fd, DWORD howlong)
 | 
			
		||||
{
 | 
			
		||||
  int res;
 | 
			
		||||
  if (!howlong)
 | 
			
		||||
    res = fhandler_base::ready_for_read (fd, howlong);
 | 
			
		||||
  else
 | 
			
		||||
    res = 1;
 | 
			
		||||
  return res;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
select_record *
 | 
			
		||||
fhandler_pipe::select_read (select_stuff *ss)
 | 
			
		||||
{
 | 
			
		||||
@@ -1236,55 +1225,6 @@ fhandler_serial::select_except (select_stuff *ss)
 | 
			
		||||
  return s;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
fhandler_base::ready_for_read (int fd, DWORD howlong)
 | 
			
		||||
{
 | 
			
		||||
  bool avail = false;
 | 
			
		||||
 | 
			
		||||
  select_stuff sel;
 | 
			
		||||
  fd_set *thisfd = allocfd_set (fd + 1);
 | 
			
		||||
  fd_set *dummy_writefds = allocfd_set (fd + 1);
 | 
			
		||||
  fd_set *dummy_exceptfds = allocfd_set (fd + 1);
 | 
			
		||||
  UNIX_FD_SET(fd, thisfd);
 | 
			
		||||
 | 
			
		||||
  if (!sel.test_and_set (fd, thisfd, dummy_writefds, dummy_exceptfds))
 | 
			
		||||
    select_printf ("aborting due to test_and_set error");
 | 
			
		||||
  else
 | 
			
		||||
    {
 | 
			
		||||
      select_record *me = sel.start.next;
 | 
			
		||||
      while (!avail)
 | 
			
		||||
	{
 | 
			
		||||
	  avail = me->read_ready ?: me->peek (me, false);
 | 
			
		||||
 | 
			
		||||
	  if (fd >= 0 && cygheap->fdtab.not_open (fd))
 | 
			
		||||
	    {
 | 
			
		||||
	      set_sig_errno (EBADF);
 | 
			
		||||
	      avail = false;
 | 
			
		||||
	      break;
 | 
			
		||||
	    }
 | 
			
		||||
 | 
			
		||||
	  if (howlong != INFINITE)
 | 
			
		||||
	    {
 | 
			
		||||
	      if (!avail)
 | 
			
		||||
		set_sig_errno (EAGAIN);
 | 
			
		||||
	      break;
 | 
			
		||||
	    }
 | 
			
		||||
 | 
			
		||||
	  if (WaitForSingleObject (signal_arrived, avail ? 0 : 10) == WAIT_OBJECT_0)
 | 
			
		||||
	    {
 | 
			
		||||
	      debug_printf ("interrupted");
 | 
			
		||||
	      set_sig_errno (EINTR);
 | 
			
		||||
	      avail = false;
 | 
			
		||||
	      break;
 | 
			
		||||
	    }
 | 
			
		||||
	}
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  select_printf ("read_ready %d, avail %d", sel.start.next->read_ready, avail);
 | 
			
		||||
  sel.cleanup ();
 | 
			
		||||
  return avail;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
select_record *
 | 
			
		||||
fhandler_base::select_read (select_stuff *ss)
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -987,19 +987,10 @@ readv (int fd, const struct iovec *const iov, const int iovcnt)
 | 
			
		||||
	  break;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
      DWORD wait = cfd->is_nonblocking () ? 0 : INFINITE;
 | 
			
		||||
 | 
			
		||||
      /* Could block, so let user know we at least got here.  */
 | 
			
		||||
      syscall_printf ("readv (%d, %p, %d) %sblocking, sigcatchers %d",
 | 
			
		||||
		      fd, iov, iovcnt, wait ? "" : "non", sigcatchers);
 | 
			
		||||
 | 
			
		||||
      if (wait && (!cfd->is_slow () || cfd->uninterruptible_io ()))
 | 
			
		||||
	/* no need to call ready_for_read */;
 | 
			
		||||
      else if (!cfd->ready_for_read (fd, wait))
 | 
			
		||||
	{
 | 
			
		||||
	  res = -1;
 | 
			
		||||
	  goto out;
 | 
			
		||||
	}
 | 
			
		||||
		      fd, iov, iovcnt, cfd->is_nonblocking () ? "non" : "",
 | 
			
		||||
		      sigcatchers);
 | 
			
		||||
 | 
			
		||||
      /* FIXME: This is not thread safe.  We need some method to
 | 
			
		||||
	 ensure that an fd, closed in another thread, aborts I/O
 | 
			
		||||
@@ -1029,7 +1020,6 @@ readv (int fd, const struct iovec *const iov, const int iovcnt)
 | 
			
		||||
	  myself->process_state &= ~PID_TTYIN;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    out:
 | 
			
		||||
      if (res >= 0 || get_errno () != EINTR || !_my_tls.call_signal_handler ())
 | 
			
		||||
	break;
 | 
			
		||||
      set_errno (e);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user