static int iostream_pump_flush(struct iostream_pump *pump) { int ret; if ((ret = o_stream_flush(pump->output)) <= 0) { if (ret < 0) { pump->callback(IOSTREAM_PUMP_STATUS_OUTPUT_ERROR, pump->context); } return ret; } pump->waiting_output = FALSE; if (pump->completed) { pump->callback(IOSTREAM_PUMP_STATUS_INPUT_EOF, pump->context); return 1; } if (pump->input->blocking) iostream_pump_copy(pump); else if (pump->io == NULL) { pump->io = io_add_istream(pump->input, iostream_pump_copy, pump); io_set_pending(pump->io); } return ret; }
void i_stream_set_input_pending(struct istream *stream, bool pending) { if (!pending) return; while (stream->real_stream->parent != NULL) { i_assert(stream->real_stream->io == NULL); stream = stream->real_stream->parent; } if (stream->real_stream->io != NULL) io_set_pending(stream->real_stream->io); }
void iostream_pump_start(struct iostream_pump *pump) { i_assert(pump != NULL); i_assert(pump->callback != NULL); /* add flush handler */ if (!pump->output->blocking) { o_stream_set_flush_callback(pump->output, iostream_pump_flush, pump); } /* make IO objects */ if (pump->input->blocking) { i_assert(!pump->output->blocking); o_stream_set_flush_pending(pump->output, TRUE); } else { pump->io = io_add_istream(pump->input, iostream_pump_copy, pump); io_set_pending(pump->io); } }