stdin: Avoid overrun errors.
authorAndre Noll <maan@systemlinux.org>
Wed, 13 Jan 2010 06:33:50 +0000 (07:33 +0100)
committerAndre Noll <maan@systemlinux.org>
Wed, 13 Jan 2010 06:33:50 +0000 (07:33 +0100)
Request a timeout of 100ms if the buffer pool is full rather
than returning an error.

error.h
stdin.c

diff --git a/error.h b/error.h
index d6a425508a207c15746e767a525ed359651d8f62..e47fa152410a90f3c03d876b6ca53786afc141f4 100644 (file)
--- a/error.h
+++ b/error.h
@@ -227,7 +227,6 @@ extern const char **para_errlist[];
 
 #define STDIN_ERRORS \
        PARA_ERROR(STDIN_EOF, "end of file"), \
-       PARA_ERROR(STDIN_OVERRUN, "stdin: output buffer overrun"), \
 
 
 
diff --git a/stdin.c b/stdin.c
index 4329e144a04ae2921a710bd28a3faae710f6b17f..868e1ed0e031744e1df39368ed241547e02fd836 100644 (file)
--- a/stdin.c
+++ b/stdin.c
@@ -53,12 +53,13 @@ static void stdin_pre_select_btr(struct sched *s, struct task *t)
 
        t->error = 0;
        ret = btr_node_status(sit->btrn, 0, BTR_NT_ROOT);
-       if (ret > 0)
-               para_fd_set(STDIN_FILENO, &s->rfds, &s->max_fileno);
-       else if (ret < 0) {
-               s->timeout.tv_sec = 0;
-               s->timeout.tv_usec = 1;
-       }
+       if (ret < 0)
+               sched_min_delay(s);
+       if (ret <= 0)
+               return;
+       if (btr_pool_unused(sit->btrp) > 0)
+               return para_fd_set(STDIN_FILENO, &s->rfds, &s->max_fileno);
+       sched_request_timeout_ms(100, s);
 }
 
 /**
@@ -111,9 +112,8 @@ static void stdin_post_select_btr(struct sched *s, struct task *t)
        if (!FD_ISSET(STDIN_FILENO, &s->rfds))
                return;
        sz = btr_pool_get_buffer(sit->btrp, &buf);
-       ret = -E_STDIN_OVERRUN;
        if (sz == 0)
-               goto err;
+               return;
        /*
         * Do not use the maximal size to avoid having only a single buffer
         * reference for the whole pool. This is bad because if that single
@@ -121,7 +121,6 @@ static void stdin_post_select_btr(struct sched *s, struct task *t)
         */
        sz = PARA_MIN(sz, btr_pool_size(sit->btrp) / 2);
        ret = read(STDIN_FILENO, buf, sz);
-       //PARA_CRIT_LOG("read ret: %d\n", ret);
        if (ret < 0)
                ret = -ERRNO_TO_PARA_ERROR(errno);
        if (ret == 0)