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:
authorCorinna Vinschen <corinna@vinschen.de>2011-05-05 22:46:38 +0400
committerCorinna Vinschen <corinna@vinschen.de>2011-05-05 22:46:38 +0400
commit23db0a41d8b178d6f3d2297834b28e015346bd43 (patch)
tree3b72886a03e084f49c3a08c711a379f9a7d22d65 /winsup/cygwin/syscalls.cc
parent8ea847494718b78a0b7e5a98cb938c9b6b801a31 (diff)
* syscalls.cc (readv): Add myfault handler. Don't check repeatedly
open state of file handler. Streamline loop. (writev): Add myfault handler.
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r--winsup/cygwin/syscalls.cc57
1 files changed, 23 insertions, 34 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 93be3ec03..b086554c5 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -962,60 +962,45 @@ readv (int fd, const struct iovec *const iov, const int iovcnt)
{
pthread_testcancel ();
- extern int sigcatchers;
- const int e = get_errno ();
+ myfault efault;
+ if (efault.faulted (EFAULT))
+ return -1;
ssize_t res = -1;
-
+ const int e = get_errno ();
const ssize_t tot = check_iovec_for_read (iov, iovcnt);
+ cygheap_fdget cfd (fd);
+ if (cfd < 0)
+ goto done;
+
if (tot <= 0)
{
res = tot;
goto done;
}
- while (1)
+ if ((cfd->get_flags () & O_ACCMODE) == O_WRONLY)
{
- cygheap_fdget cfd (fd);
- if (cfd < 0)
- break;
-
- if ((cfd->get_flags () & O_ACCMODE) == O_WRONLY)
- {
- set_errno (EBADF);
- break;
- }
-
- /* Could block, so let user know we at least got here. */
- syscall_printf ("readv (%d, %p, %d) %sblocking, sigcatchers %d",
- fd, iov, iovcnt, cfd->is_nonblocking () ? "non" : "",
- sigcatchers);
+ set_errno (EBADF);
+ goto done;
+ }
- /* 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 ())
- break;
+ /* Could block, so let user know we at least got here. */
+ extern int sigcatchers;
+ syscall_printf ("readv (%d, %p, %d) %sblocking, sigcatchers %d",
+ fd, iov, iovcnt, cfd->is_nonblocking () ? "non" : "",
+ sigcatchers);
+ while (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 ())
- {
- res = -1;
- break;
- }
-
if (res > bg_eof)
{
myself->process_state |= PID_TTYIN;
- if (!cfd.isopen ())
- {
- res = -1;
- break;
- }
res = cfd->readv (iov, iovcnt, tot);
myself->process_state &= ~PID_TTYIN;
}
@@ -1037,6 +1022,10 @@ writev (const int fd, const struct iovec *const iov, const int iovcnt)
{
pthread_testcancel ();
+ myfault efault;
+ if (efault.faulted (EFAULT))
+ return -1;
+
int res = -1;
const ssize_t tot = check_iovec_for_write (iov, iovcnt);