From d2466c7aa03059682924cec3ae1919a7fdb4795e Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Mon, 28 Jul 2003 21:13:17 +0000 Subject: * fhandler_base.cc (fhandler_base::readv): Rework to properly return number of bytes from read. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/fhandler.cc | 15 ++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) (limited to 'winsup/cygwin') 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 + + * fhandler_base.cc (fhandler_base::readv): Rework to properly return + number of bytes from read. + 2003-07-26 Christopher Faylor * 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 -- cgit v1.2.3