Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2001-09-22 20:55:02 +0400
committerChristopher Faylor <me@cgf.cx>2001-09-22 20:55:02 +0400
commit5e733918c085833e32581ac0bb0437b00ad2aa8e (patch)
tree1a6e4725f8c88ede60c41c445c98d685224cd85a /winsup/cygwin/select.cc
parent142920f65aeeefc29ef903b75b6327668341bc8e (diff)
* exceptions.cc (setup_handler): Always relinquish lock after we've
interrupted. * fhandler.cc: Move pipe methods to pipe.cc. * fhandler.h (fhandler_pipe): Add new methods. * fork.cc (sync_with_parent): Make error messages more informative. * pipe.cc (fhandler_pipe::fhandler_pipe): Move here from fhandler.cc. (fhandler_pipe::lseek): Ditto. (fhandler_pipe::set_close_on_exec): New method. (fhandler_pipe::read): Ditto. (fhandler_pipe::close): Ditto. (fhandler_pipe::dup): Ditto. (make_pipe): Create the guard mutex on the read side of the pipe. * select.cc (peek_pipe): Use guard_mutex to discover if we have the right to read on this pipe. (fhandler_pipe::readh_for_read): Pass the read pipe guard mutex to peek_pipe. * syscalls.cc (_read): Always detect signal catchers, for now. * debug.cc (makethread): Eliminate hack to make thread inheritable. * sigproc.cc (subproc_init): Don't use hack to make thread inheritable.
Diffstat (limited to 'winsup/cygwin/select.cc')
-rw-r--r--winsup/cygwin/select.cc37
1 files changed, 24 insertions, 13 deletions
diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
index 94326dc41..67365d925 100644
--- a/winsup/cygwin/select.cc
+++ b/winsup/cygwin/select.cc
@@ -123,14 +123,6 @@ cygwin_select (int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
fd_set *dummy_exceptfds = allocfd_set (maxfds);
sigframe thisframe (mainthread);
-#if 0
- if (n > FD_SETSIZE)
- {
- set_errno (EINVAL);
- return -1;
- }
-#endif
-
select_printf ("%d, %p, %p, %p, %p", maxfds, readfds, writefds, exceptfds, to);
if (!readfds)
@@ -407,7 +399,7 @@ no_verify (select_record *, fd_set *, fd_set *, fd_set *)
}
static int
-peek_pipe (select_record *s, int ignra)
+peek_pipe (select_record *s, int ignra, HANDLE guard_mutex = NULL)
{
int n = 0;
int gotone = 0;
@@ -454,8 +446,15 @@ peek_pipe (select_record *s, int ignra)
}
}
- if (fh->get_device() != FH_PIPEW &&
- !PeekNamedPipe (h, NULL, 0, NULL, (DWORD *) &n, NULL))
+ if (fh->get_device () == FH_PIPEW)
+ /* nothing */;
+ else if (guard_mutex && WaitForSingleObject (guard_mutex, 0) != WAIT_OBJECT_0)
+ {
+ select_printf ("%s, couldn't get mutex %p, %E", fh->get_name (),
+ guard_mutex);
+ n = 0;
+ }
+ else if (!PeekNamedPipe (h, NULL, 0, NULL, (DWORD *) &n, NULL))
{
select_printf ("%s, PeekNamedPipe failed, %E", fh->get_name ());
n = -1;
@@ -496,8 +495,20 @@ poll_pipe (select_record *me, fd_set *readfds, fd_set *writefds,
set_bits (me, readfds, writefds, exceptfds) :
0;
}
-
-MAKEready(pipe)
+int
+fhandler_pipe::ready_for_read (int fd, DWORD howlong, int ignra)
+{
+ select_record me (this);
+ me.fd = fd;
+ (void) select_read (&me);
+ while (!peek_pipe (&me, ignra, guard) && howlong == INFINITE)
+ if (fd >= 0 && cygheap->fdtab.not_open (fd))
+ break;
+ else if (WaitForSingleObject (signal_arrived, 10) == WAIT_OBJECT_0)
+ break;
+ select_printf ("returning %d", me.read_ready);
+ return me.read_ready;
+}
static int start_thread_pipe (select_record *me, select_stuff *stuff);