- sz = btr_pool_get_buffer(pdd->btrp, &buf);
- if (sz == 0)
- goto err;
- ret = recv_bin_buffer(pdd->fd, buf, sz);
- if (ret == 0)
- ret = -E_RECV_EOF;
- if (ret < 0)
- goto err;
- btr_add_output_pool(pdd->btrp, ret, btrn);
- return;
-err:
+ if (iovcnt == 0)
+ goto out;
+ ret = readv_nonblock(pdd->fd, iov, iovcnt, &s->rfds, &num_bytes);
+ if (num_bytes == 0)
+ goto out;
+ if (num_bytes <= iov[0].iov_len) /* only the first buffer was filled */
+ btr_add_output_pool(pdd->btrp, num_bytes, btrn);
+ else { /* both buffers contain data */
+ btr_add_output_pool(pdd->btrp, iov[0].iov_len, btrn);
+ btr_add_output_pool(pdd->btrp, num_bytes - iov[0].iov_len, btrn);
+ }
+out:
+ if (ret >= 0)
+ return;