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
path: root/winsup
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2001-11-02 02:48:34 +0300
committerChristopher Faylor <me@cgf.cx>2001-11-02 02:48:34 +0300
commit53f00290819bd294d31d12bb93e8e5e887ad3aef (patch)
treef106c6e3e9c62c567b4aa8e42c0327f7845d4fde /winsup
parent1229d4f4eeec60957897cbf851adff5f61ab4df5 (diff)
* cygheap.h (cygheap_fdmanip::isopen): Set appropriate errno if fd not open.
* select.cc (fhandler_base::ready_for_read): Release an open guard mutex when exiting with an error condition. * syscalls.cc (_read): Check frequently for closed fd as a kludge until something better is invented.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog9
-rw-r--r--winsup/cygwin/cygheap.h8
-rw-r--r--winsup/cygwin/select.cc3
-rw-r--r--winsup/cygwin/syscalls.cc11
4 files changed, 29 insertions, 2 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 76f437f1b..a12d86609 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,14 @@
2001-11-01 Christopher Faylor <cgf@redhat.com>
+ * cygheap.h (cygheap_fdmanip::isopen): Set appropriate errno if fd not
+ open.
+ * select.cc (fhandler_base::ready_for_read): Release an open guard
+ mutex when exiting with an error condition.
+ * syscalls.cc (_read): Check frequently for closed fd as a kludge until
+ something better is invented.
+
+2001-11-01 Christopher Faylor <cgf@redhat.com>
+
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown
device.
* fhandler.cc (fhandler_base::close): Show both name and handle in
diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h
index 5b868040f..27196db88 100644
--- a/winsup/cygwin/cygheap.h
+++ b/winsup/cygwin/cygheap.h
@@ -198,7 +198,13 @@ class cygheap_fdmanip
operator fhandler_base* &() {return *fh;}
void operator = (fhandler_base *fh) {*this->fh = fh;}
fhandler_base *operator -> () const {return *fh;}
- bool isopen () const {return *fh;}
+ bool isopen () const
+ {
+ if (*fh)
+ return true;
+ set_errno (EBADF);
+ return false;
+ }
};
class cygheap_fdnew : public cygheap_fdmanip
diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
index 2b807e388..bcfc56f02 100644
--- a/winsup/cygwin/select.cc
+++ b/winsup/cygwin/select.cc
@@ -1102,6 +1102,9 @@ fhandler_base::ready_for_read (int fd, DWORD howlong, int ignra)
}
}
+ if (get_guard () && !avail && me.read_ready)
+ ReleaseMutex (get_guard ());
+
select_printf ("read_ready %d, avail %d", me.read_ready, avail);
return avail;
}
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 164e3242c..b11e6795b 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -310,7 +310,7 @@ _read (int fd, void *ptr, size_t len)
/* Could block, so let user know we at least got here. */
syscall_printf ("read (%d, %p, %d) %sblocking, sigcatchers %d", fd, ptr, len, wait ? "" : "non", sigcatchers);
- if (wait && (/*!sigcatchers || */!cfd->is_slow () || cfd->get_r_no_interrupt ()))
+ if (wait && (!cfd->is_slow () || cfd->get_r_no_interrupt ()))
debug_printf ("non-interruptible read\n");
else if (!cfd->ready_for_read (fd, wait, 0))
{
@@ -318,15 +318,24 @@ _read (int fd, void *ptr, size_t len)
goto out;
}
+ /* FIXME: This is not thread safe. We need some method to
+ ensure that an fd, closed in another thread, aborts I/O
+ operations. */
if (!cfd.isopen())
return -1;
/* Check to see if this is a background read from a "tty",
sending a SIGTTIN, if appropriate */
res = cfd->bg_check (SIGTTIN);
+
+ if (!cfd.isopen())
+ return -1;
+
if (res > bg_eof)
{
myself->process_state |= PID_TTYIN;
+ if (!cfd.isopen())
+ return -1;
res = cfd->read (ptr, len);
myself->process_state &= ~PID_TTYIN;
}