- ret = read(STDIN_FILENO, sit->buf + sit->loaded, sit->bufsize - sit->loaded);
- if (ret < 0)
- t->error = ERRNO_TO_PARA_ERROR(errno);
- else if (ret > 0)
- sit->loaded += ret;
- else
- t->error = -E_STDIN_EOF;
+ /*
+ * 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
+ * reference can not be freed, we're stuck.
+ */
+ sz = PARA_MIN(sz, btr_pool_size(sit->btrp) / 2);
+ ret = read_nonblock(STDIN_FILENO, buf, sz, &s->rfds, &n);
+ if (n > 0)
+ btr_add_output_pool(sit->btrp, n, sit->btrn);
+ if (ret >= 0)
+ return;
+err:
+ btr_remove_node(sit->btrn);
+ //btr_pool_free(sit->btrp);
+ t->error = ret;