]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - stdout.c
file writer pre_select() fixes.
[paraslash.git] / stdout.c
index 6539b68f3ff8f91befc8d99cf6b5c3002b2b9e98..bf4a923de06c466c0234bae9da301f1b294f11cb 100644 (file)
--- a/stdout.c
+++ b/stdout.c
@@ -54,8 +54,6 @@ static void stdout_pre_select_btr(struct sched *s, struct task *t)
        sot->check_fd = 0;
        if (sz == 0) {
                if (btr_no_parent(sot->btrn)) {
-                       t->error = -E_ORPHAN;
-                       btr_del_node(sot->btrn);
                        s->timeout.tv_sec = 0;
                        s->timeout.tv_usec = 1;
                }
@@ -104,13 +102,12 @@ static void stdout_post_select_btr(struct sched *s, struct task *t)
        struct stdout_task *sot = container_of(t, struct stdout_task, task);
        ssize_t ret;
        size_t sz = btr_get_input_queue_size(sot->btrn);
-       bool orphan = btr_no_parent(sot->btrn);
        char *buf;
 
        t->error = 0;
        if (!sot->check_fd) {
-               if (sz == 0 && orphan) {
-                       t->error = -E_ORPHAN;
+               if (sz == 0 && btr_no_parent(sot->btrn)) {
+                       t->error = -E_STDOUT_EOF;
                        goto err;
                }
                return;
@@ -120,7 +117,7 @@ static void stdout_post_select_btr(struct sched *s, struct task *t)
        sz = btr_next_buffer(sot->btrn, &buf);
        if (sz == 0)
                return;
-       ret = write(STDOUT_FILENO, buf, sz);
+       ret = write_nonblock(STDOUT_FILENO, buf, sz, 0);
        if (ret < 0) {
                t->error = -ERRNO_TO_PARA_ERROR(errno);
                goto err;
@@ -128,7 +125,7 @@ static void stdout_post_select_btr(struct sched *s, struct task *t)
        btr_consume(sot->btrn, ret);
        return;
 err:
-       btr_del_node(sot->btrn);
+       btr_remove_node(sot->btrn);
 }
 /**
  * Initialize a stdout task structure with default values.