* fhandler_base.cc (fhandler_base::readv): Rework to properly return number of
bytes from read.
This commit is contained in:
parent
df4b5a9c5a
commit
d2466c7aa0
@ -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>
|
2003-07-26 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
* exceptions.cc (ctrl_c_handler): Send SIGHUP when events occur only if
|
* exceptions.cc (ctrl_c_handler): Send SIGHUP when events occur only if
|
||||||
|
@ -758,28 +758,29 @@ fhandler_base::readv (const struct iovec *const iov, const int iovcnt,
|
|||||||
assert (iov);
|
assert (iov);
|
||||||
assert (iovcnt >= 1);
|
assert (iovcnt >= 1);
|
||||||
|
|
||||||
|
size_t len = tot;
|
||||||
if (iovcnt == 1)
|
if (iovcnt == 1)
|
||||||
{
|
{
|
||||||
size_t len = iov->iov_len;
|
len = iov->iov_len;
|
||||||
read (iov->iov_base, len);
|
read (iov->iov_base, len);
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tot == -1) // i.e. if not pre-calculated by the caller.
|
if (tot == -1) // i.e. if not pre-calculated by the caller.
|
||||||
{
|
{
|
||||||
tot = 0;
|
len = 0;
|
||||||
const struct iovec *iovptr = iov + iovcnt;
|
const struct iovec *iovptr = iov + iovcnt;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
iovptr -= 1;
|
iovptr -= 1;
|
||||||
tot += iovptr->iov_len;
|
len += iovptr->iov_len;
|
||||||
}
|
}
|
||||||
while (iovptr != iov);
|
while (iovptr != iov);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert (tot >= 0);
|
assert (tot >= 0);
|
||||||
|
|
||||||
if (tot == 0)
|
if (!len)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
char *buf = (char *) alloca (tot);
|
char *buf = (char *) alloca (tot);
|
||||||
@ -790,10 +791,10 @@ fhandler_base::readv (const struct iovec *const iov, const int iovcnt,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
read (buf, (size_t) tot);
|
read (buf, len);
|
||||||
|
ssize_t nbytes = (ssize_t) len;
|
||||||
|
|
||||||
const struct iovec *iovptr = iov;
|
const struct iovec *iovptr = iov;
|
||||||
int nbytes = tot;
|
|
||||||
|
|
||||||
while (nbytes > 0)
|
while (nbytes > 0)
|
||||||
{
|
{
|
||||||
@ -804,7 +805,7 @@ fhandler_base::readv (const struct iovec *const iov, const int iovcnt,
|
|||||||
nbytes -= frag;
|
nbytes -= frag;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tot;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
|
Loading…
x
Reference in New Issue
Block a user