X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=http_recv.c;h=9ade8dfbc4063d2f9179c190c2e8233bf22c56ae;hp=cc376dd9a6e0c07c1dfe9f368aebdd1fbaf98c85;hb=96dd1284a1b7d565560979fdc7ec647aeceb6b52;hpb=b0fe6d882dd35b01360a66e130d6714aff7b6a0d diff --git a/http_recv.c b/http_recv.c index cc376dd9..9ade8dfb 100644 --- a/http_recv.c +++ b/http_recv.c @@ -95,7 +95,7 @@ static void http_recv_post_select(struct sched *s, struct task *t) struct btr_node *btrn = rn->btrn; int ret; char *buf; - size_t sz; + size_t sz, n; t->error = 0; ret = btr_node_status(btrn, 0, BTR_NT_ROOT); @@ -116,12 +116,12 @@ static void http_recv_post_select(struct sched *s, struct task *t) phd->status = HTTP_SENT_GET_REQUEST; return; } - if (!FD_ISSET(phd->fd, &s->rfds)) - return; if (phd->status == HTTP_SENT_GET_REQUEST) { - ret = recv_pattern(phd->fd, HTTP_OK_MSG, strlen(HTTP_OK_MSG)); + ret = read_pattern(phd->fd, HTTP_OK_MSG, strlen(HTTP_OK_MSG), &s->rfds); if (ret < 0) goto err; + if (ret == 0) + return; PARA_INFO_LOG("received ok msg, streaming\n"); phd->status = HTTP_STREAMING; return; @@ -130,13 +130,11 @@ static void http_recv_post_select(struct sched *s, struct task *t) sz = btr_pool_get_buffer(phd->btrp, &buf); if (sz == 0) goto err; - ret = recv_bin_buffer(phd->fd, buf, sz); - if (ret == 0) - ret = -E_RECV_EOF; - if (ret < 0) - goto err; - btr_add_output_pool(phd->btrp, ret, btrn); - return; + ret = read_nonblock(phd->fd, buf, sz, &s->rfds, &n); + if (n > 0) + btr_add_output_pool(phd->btrp, n, btrn); + if (ret >= 0) + return; err: btr_remove_node(rn->btrn); t->error = ret;