}
#endif
- *rbuflen = MIN(reqcount, *rbuflen);
+ *rbuflen = MIN(reqcount, dsi->server_quantum);
- cc = read_file(ofork, eid, offset, rbuf, rbuflen);
+ cc = read_file(ofork, eid, offset, ibuf, rbuflen);
if (cc < 0) {
err = cc;
goto afp_read_done;
* we know that we're sending some data. if we fail, something
* horrible happened.
*/
- if ((cc = dsi_readinit(dsi, rbuf, *rbuflen, reqcount, err)) < 0)
+ if ((cc = dsi_readinit(dsi, ibuf, *rbuflen, reqcount, err)) < 0)
goto afp_read_exit;
*rbuflen = cc;
while (*rbuflen > 0) {
- cc = read_file(ofork, eid, offset, rbuf, rbuflen);
+ /*
+ * This loop isn't really entered anymore, we've already
+ * sent the whole requested block in dsi_readinit().
+ */
+ cc = read_file(ofork, eid, offset, ibuf, rbuflen);
if (cc < 0)
goto afp_read_exit;
offset += *rbuflen;
/* dsi_read() also returns buffer size of next allocation */
- cc = dsi_read(dsi, rbuf, *rbuflen); /* send it off */
+ cc = dsi_read(dsi, ibuf, *rbuflen); /* send it off */
if (cc < 0)
goto afp_read_exit;
*rbuflen = cc;
{
char block[DSI_BLOCKSIZ];
struct iovec iov[2];
+ int iovecs = 2;
size_t towrite;
ssize_t len;
towrite = sizeof(block) + length;
dsi->write_count += towrite;
while (towrite > 0) {
- if (((len = writev(dsi->socket, iov, 2)) == -1 && errno == EINTR) || (len == 0))
+ if (((len = writev(dsi->socket, iov, iovecs)) == -1 && errno == EINTR) || (len == 0))
continue;
if ((size_t)len == towrite) /* wrote everything out */
iov[0].iov_base = (char *) iov[0].iov_base + len;
iov[0].iov_len -= len;
} else { /* skip to data */
- if (iov[0].iov_len) {
+ if (iovecs == 2) {
+ iovecs = 1;
len -= iov[0].iov_len;
- iov[0].iov_len = 0;
+ iov[0] = iov[1];
}
- iov[1].iov_base = (char *) iov[1].iov_base + len;
- iov[1].iov_len -= len;
+ iov[0].iov_base = (char *) iov[0].iov_base + len;
+ iov[0].iov_len -= len;
}
}