#include "string.h"
#include "net.h"
#include "fd.h"
+#include "buffer_tree.h"
#include "dccp_recv.cmdline.h"
struct private_dccp_recv_data {
/** the file descriptor for the dccp socket */
int fd;
+ struct btr_pool *btrp;
};
goto err;
rn->buf = para_calloc(DCCP_BUFSIZE);
rn->private_data = pdd = para_calloc(sizeof(struct private_dccp_recv_data));
+ pdd->btrp = btr_pool_new("dccp_recv", 320 * 1024);
pdd->fd = fd;
return 1;
err:
struct receiver_node *rn = container_of(t, struct receiver_node, task);
struct private_dccp_recv_data *pdd = rn->private_data;
+ if (rn->btrn)
+ if (generic_recv_pre_select(s, t) <= 0)
+ return;
t->error = 0;
para_fd_set(pdd->fd, &s->rfds, &s->max_fileno);
}
{
struct receiver_node *rn = container_of(t, struct receiver_node, task);
struct private_dccp_recv_data *pdd = rn->private_data;
-
- if (rn->output_error && *rn->output_error < 0) {
- t->error = *rn->output_error;
- return;
+ struct btr_node *btrn = rn->btrn;
+ int ret;
+
+ if (btrn) {
+ ret = btr_node_status(btrn, 0, BTR_NT_ROOT);
+ if (ret < 0)
+ goto err;
+ if (ret == 0)
+ return;
+ } else {
+ if (rn->output_error && *rn->output_error < 0) {
+ t->error = *rn->output_error;
+ return;
+ }
}
if (!FD_ISSET(pdd->fd, &s->rfds))
return; /* nothing to do */
t->error = -E_DCCP_OVERRUN;
return;
}
+ if (btrn) {
+ char *buf;
+ size_t sz;
+
+ sz = btr_pool_get_buffer(pdd->btrp, &buf);
+ ret = -E_DCCP_OVERRUN;
+ if (sz == 0)
+ goto err;
+ //buf = para_malloc(HTTP_RECV_READ_BUF_SIZE);
+ //sz = HTTP_RECV_READ_BUF_SIZE;
+ 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;
+ }
t->error = recv_bin_buffer(pdd->fd, rn->buf + rn->loaded,
DCCP_BUFSIZE - rn->loaded);
if (t->error > 0) {
}
if (!t->error)
t->error = -E_RECV_EOF;
+ return;
+err:
+ if (btrn)
+ btr_remove_node(rn->btrn);
+ t->error = ret;
}
static void dccp_recv_free_config(void *conf)