* 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.
This commit is contained in:
parent
1229d4f4ee
commit
53f0029081
|
@ -1,3 +1,12 @@
|
|||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue