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;
}
/**
*
* \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)
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;