-
- buf = para_malloc(STDIN_INPUT_BUFFER_SIZE);
- ret = read(STDIN_FILENO, buf, STDIN_INPUT_BUFFER_SIZE);
+ sz = btr_pool_get_buffer(sit->btrp, &buf);
+ ret = -E_STDIN_OVERRUN;
+ if (sz == 0)
+ goto err;
+ /*
+ * 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(STDIN_FILENO, buf, sz);
+ //PARA_CRIT_LOG("read ret: %d\n", ret);