X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=stdout.c;h=34fe08cd6a46e8305fa990988b1408f056fad191;hp=16e16465ad2d9671c6d9e818f10caed6aae2cb91;hb=3bb5d9c5f7e30c5b4d2216171ee9aff1389d70ae;hpb=6d92af64de5e78ded1a7cb27a88d7e10c9f576a8 diff --git a/stdout.c b/stdout.c index 16e16465..34fe08cd 100644 --- a/stdout.c +++ b/stdout.c @@ -106,20 +106,24 @@ static void stdout_post_select_btr(struct sched *s, struct task *t) t->error = 0; ret = btr_node_status(btrn, 0, BTR_NT_LEAF); if (ret < 0) - goto err; + goto out; if (ret == 0) return; if (!FD_ISSET(STDOUT_FILENO, &s->wfds)) return; - sz = btr_next_buffer(btrn, &buf); - assert(sz > 0); - ret = write_nonblock(STDOUT_FILENO, buf, sz, 0); + + for (;;) { + sz = btr_next_buffer(btrn, &buf); + if (sz == 0) + break; + ret = write_nonblock(STDOUT_FILENO, buf, sz, 0); + if (ret <= 0) + break; + btr_consume(btrn, ret); + } +out: if (ret < 0) - goto err; - btr_consume(btrn, ret); - return; -err: - btr_remove_node(btrn); + btr_remove_node(btrn); t->error = ret; } /** @@ -127,7 +131,7 @@ err: * * \param sot The stdout task structure. * - * This fills in the pre/post select function poinzters of the task structure + * This fills in the pre/post select function pointers of the task structure * given by \a sot. */ void stdout_set_defaults(struct stdout_task *sot) @@ -141,7 +145,7 @@ void stdout_set_defaults(struct stdout_task *sot) sot->task.pre_select = stdout_pre_select; sot->task.post_select = stdout_post_select; } - sprintf(sot->task.status, "stdout writer"); + sprintf(sot->task.status, "stdout"); ret = mark_fd_nonblocking(STDOUT_FILENO); if (ret >= 0) return;