diff options
author | Christopher Faylor <me@cgf.cx> | 2001-11-03 05:42:21 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2001-11-03 05:42:21 +0000 |
commit | c41570695a46cf3a4f1cf3f72db353c963f40f7e (patch) | |
tree | c46d10c143594b112016b62f07ddfa3d3d79a85f /winsup/cygwin/select.cc | |
parent | 243a041bd0164aa62813ac4ba5a1a02eb2db455b (diff) | |
download | cygnal-c41570695a46cf3a4f1cf3f72db353c963f40f7e.tar.gz cygnal-c41570695a46cf3a4f1cf3f72db353c963f40f7e.tar.bz2 cygnal-c41570695a46cf3a4f1cf3f72db353c963f40f7e.zip |
* fhandler.cc (fhandler_base::read): Return just read ahead characters if slow
device.
* fhandler.h (fhandler_base::set_eof): New virtual method.
(fhandler_pipe::set_eof): New method.
* pipe.cc (fhandler_pipe::fhandler_pipe): Clear saweof flag.
(fhandler_pipe::read): Return immediately if hit eof.
(fhandler_pipe::hit_eof): Return true if saweof flag is set.
* select.cc (peek_pipe): Don't call PeekNamedPipe if we couldn't grab the guard
mutex.
Diffstat (limited to 'winsup/cygwin/select.cc')
-rw-r--r-- | winsup/cygwin/select.cc | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc index 78d1aaabe..e2bd711ba 100644 --- a/winsup/cygwin/select.cc +++ b/winsup/cygwin/select.cc @@ -389,9 +389,9 @@ peek_pipe (select_record *s, int ignra) fhandler_base *fh = s->fh; HANDLE h; - HANDLE guard_mutex = fh->get_guard (); set_handle_or_return_if_not_open (h, s); + HANDLE guard_mutex = fh->get_guard (); /* Don't perform complicated tests if we don't need to. */ if (!s->read_selected && !s->except_selected) goto out; @@ -438,16 +438,18 @@ peek_pipe (select_record *s, int ignra) select_printf ("%s, PeekNamedPipe failed, %E", fh->get_name ()); n = -1; } - else if (n && guard_mutex) + else if (!n || !guard_mutex) + /* nothing */; + else if (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 (WaitForSingleObject (guard_mutex, 0) != WAIT_OBJECT_0) - { - select_printf ("%s, couldn't get mutex %p, %E", fh->get_name (), - guard_mutex); - n = 0; - } /* Now that we have the mutex, make sure that no one else has snuck - in and grabbed the data that we originally saw. */ + in and grabbed the data that we originally saw. */ if (!PeekNamedPipe (h, NULL, 0, NULL, (DWORD *) &n, NULL)) { select_printf ("%s, PeekNamedPipe failed, %E", fh->get_name ()); @@ -459,6 +461,7 @@ peek_pipe (select_record *s, int ignra) if (n < 0) { + fh->set_eof (); select_printf ("%s, n %d", fh->get_name (), n); if (s->except_selected) gotone += s->except_ready = TRUE; |