Fix test rw_blocking
This commit is contained in:
+6
-4
@@ -60,7 +60,7 @@ int readv_blocking(int fd, iovec *iov, int iovcnt)
|
|||||||
int done = 0;
|
int done = 0;
|
||||||
while (v < iovcnt)
|
while (v < iovcnt)
|
||||||
{
|
{
|
||||||
ssize_t r = readv(fd, iov, iovcnt);
|
ssize_t r = readv(fd, iov+v, iovcnt-v);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
{
|
{
|
||||||
if (errno != EAGAIN && errno != EPIPE)
|
if (errno != EAGAIN && errno != EPIPE)
|
||||||
@@ -70,6 +70,7 @@ int readv_blocking(int fd, iovec *iov, int iovcnt)
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
done += r;
|
||||||
while (v < iovcnt)
|
while (v < iovcnt)
|
||||||
{
|
{
|
||||||
if (iov[v].iov_len > r)
|
if (iov[v].iov_len > r)
|
||||||
@@ -80,10 +81,10 @@ int readv_blocking(int fd, iovec *iov, int iovcnt)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
r -= iov[v].iov_len;
|
||||||
v++;
|
v++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
done += r;
|
|
||||||
}
|
}
|
||||||
return done;
|
return done;
|
||||||
}
|
}
|
||||||
@@ -94,7 +95,7 @@ int writev_blocking(int fd, iovec *iov, int iovcnt)
|
|||||||
int done = 0;
|
int done = 0;
|
||||||
while (v < iovcnt)
|
while (v < iovcnt)
|
||||||
{
|
{
|
||||||
ssize_t r = writev(fd, iov, iovcnt);
|
ssize_t r = writev(fd, iov+v, iovcnt-v);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
{
|
{
|
||||||
if (errno != EAGAIN && errno != EPIPE)
|
if (errno != EAGAIN && errno != EPIPE)
|
||||||
@@ -104,6 +105,7 @@ int writev_blocking(int fd, iovec *iov, int iovcnt)
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
done += r;
|
||||||
while (v < iovcnt)
|
while (v < iovcnt)
|
||||||
{
|
{
|
||||||
if (iov[v].iov_len > r)
|
if (iov[v].iov_len > r)
|
||||||
@@ -114,10 +116,10 @@ int writev_blocking(int fd, iovec *iov, int iovcnt)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
r -= iov[v].iov_len;
|
||||||
v++;
|
v++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
done += r;
|
|
||||||
}
|
}
|
||||||
return done;
|
return done;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -116,7 +116,7 @@ int bind_stub(const char *bind_address, int bind_port)
|
|||||||
void run_stub(int peer_fd)
|
void run_stub(int peer_fd)
|
||||||
{
|
{
|
||||||
osd_any_op_t op;
|
osd_any_op_t op;
|
||||||
osd_any_reply_t reply;
|
osd_any_reply_t reply = { 0 };
|
||||||
void *buf = NULL;
|
void *buf = NULL;
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
@@ -139,7 +139,7 @@ void run_stub(int peer_fd)
|
|||||||
buf = malloc(op.sec_rw.len);
|
buf = malloc(op.sec_rw.len);
|
||||||
r = write_blocking(peer_fd, reply.buf, OSD_PACKET_SIZE);
|
r = write_blocking(peer_fd, reply.buf, OSD_PACKET_SIZE);
|
||||||
if (r == OSD_PACKET_SIZE)
|
if (r == OSD_PACKET_SIZE)
|
||||||
r = write_blocking(peer_fd, &buf, op.sec_rw.len);
|
r = write_blocking(peer_fd, buf, op.sec_rw.len);
|
||||||
free(buf);
|
free(buf);
|
||||||
if (r < op.sec_rw.len)
|
if (r < op.sec_rw.len)
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user