From: Andre Noll Date: Sun, 10 Jan 2010 18:49:58 +0000 (+0100) Subject: stdout: Try to write as much as possible in one go. X-Git-Tag: v0.4.2~167 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=3bb5d9c5f7e30c5b4d2216171ee9aff1389d70ae;p=paraslash.git stdout: Try to write as much as possible in one go. --- 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;