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>2003-07-29 01:13:17 +0400
committerChristopher Faylor <me@cgf.cx>2003-07-29 01:13:17 +0400
commitd2466c7aa03059682924cec3ae1919a7fdb4795e (patch)
tree64127b3368e111c65bfa6c56e51dba67d657f1c0 /winsup/cygwin
parentdf4b5a9c5a4d063ad09aea1755cae0dc778853c5 (diff)
* fhandler_base.cc (fhandler_base::readv): Rework to properly return number of
bytes from read.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r--winsup/cygwin/ChangeLog5
-rw-r--r--winsup/cygwin/fhandler.cc15
2 files changed, 13 insertions, 7 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 2c9ec5043..1304fd88a 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,8 @@
+2003-07-28 Christopher Faylor <cgf@redhat.com>
+
+ * fhandler_base.cc (fhandler_base::readv): Rework to properly return
+ number of bytes from read.
+
2003-07-26 Christopher Faylor <cgf@redhat.com>
* exceptions.cc (ctrl_c_handler): Send SIGHUP when events occur only if
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index 2ab56f5da..ef0328d44 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -758,28 +758,29 @@ fhandler_base::readv (const struct iovec *const iov, const int iovcnt,
assert (iov);
assert (iovcnt >= 1);
+ size_t len = tot;
if (iovcnt == 1)
{
- size_t len = iov->iov_len;
+ len = iov->iov_len;
read (iov->iov_base, len);
return len;
}
if (tot == -1) // i.e. if not pre-calculated by the caller.
{
- tot = 0;
+ len = 0;
const struct iovec *iovptr = iov + iovcnt;
do
{
iovptr -= 1;
- tot += iovptr->iov_len;
+ len += iovptr->iov_len;
}
while (iovptr != iov);
}
assert (tot >= 0);
- if (tot == 0)
+ if (!len)
return 0;
char *buf = (char *) alloca (tot);
@@ -790,10 +791,10 @@ fhandler_base::readv (const struct iovec *const iov, const int iovcnt,
return -1;
}
- read (buf, (size_t) tot);
+ read (buf, len);
+ ssize_t nbytes = (ssize_t) len;
const struct iovec *iovptr = iov;
- int nbytes = tot;
while (nbytes > 0)
{
@@ -804,7 +805,7 @@ fhandler_base::readv (const struct iovec *const iov, const int iovcnt,
nbytes -= frag;
}
- return tot;
+ return len;
}
ssize_t