/*
- * Copyright (C) 2006-2010 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2006-2011 Andre Noll <maan@systemlinux.org>
*
* Licensed under the GPL v2. For licencing details see COPYING.
*/
struct btr_node *btrn = rn->btrn;
struct iovec iov[2];
int ret, iovcnt;
+ size_t num_bytes;
ret = btr_node_status(btrn, 0, BTR_NT_ROOT);
- if (ret < 0)
- goto err;
- if (ret == 0)
- return;
- if (!FD_ISSET(pdd->fd, &s->rfds))
- return; /* nothing to do */
+ if (ret <= 0)
+ goto out;
iovcnt = btr_pool_get_buffers(pdd->btrp, iov);
ret = -E_DCCP_OVERRUN;
if (iovcnt == 0)
- goto err;
- ret = para_readv(pdd->fd, iov, iovcnt);
- /* EAGAIN is possible even if FD_ISSET */
- if (ret < 0 && is_errno(-ret, EAGAIN))
- return;
- if (ret == 0)
- ret = -E_RECV_EOF;
- if (ret < 0)
- goto err;
- if (ret <= iov[0].iov_len) /* only the first buffer was filled */
- btr_add_output_pool(pdd->btrp, ret, btrn);
+ 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, ret - iov[0].iov_len, btrn);
+ btr_add_output_pool(pdd->btrp, num_bytes - iov[0].iov_len, btrn);
}
- return;
-err:
+out:
+ if (ret >= 0)
+ return;
btr_remove_node(rn->btrn);
t->error = ret;
}