Benchmark reads in stub_bench, too
This commit is contained in:
@@ -51,6 +51,40 @@ int write_blocking(int fd, void *write_buf, size_t remaining)
|
||||
return done;
|
||||
}
|
||||
|
||||
int readv_blocking(int fd, iovec *iov, int iovcnt)
|
||||
{
|
||||
int v = 0;
|
||||
int done = 0;
|
||||
while (v < iovcnt)
|
||||
{
|
||||
ssize_t r = readv(fd, iov, iovcnt);
|
||||
if (r < 0)
|
||||
{
|
||||
if (errno != EAGAIN && errno != EPIPE)
|
||||
{
|
||||
perror("writev");
|
||||
exit(1);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
while (v < iovcnt)
|
||||
{
|
||||
if (iov[v].iov_len > r)
|
||||
{
|
||||
iov[v].iov_len -= r;
|
||||
iov[v].iov_base += r;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
v++;
|
||||
}
|
||||
}
|
||||
done += r;
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
int writev_blocking(int fd, iovec *iov, int iovcnt)
|
||||
{
|
||||
int v = 0;
|
||||
|
||||
Reference in New Issue
Block a user