iostream_pump_callback_t *callback;
void *context;
+
+ bool waiting_output;
bool completed;
};
pump->callback(FALSE, pump->context);
return;
case OSTREAM_SEND_ISTREAM_RESULT_WAIT_OUTPUT:
+ pump->waiting_output = TRUE;
io_remove(&pump->io);
return;
case OSTREAM_SEND_ISTREAM_RESULT_FINISHED:
+ pump->waiting_output = FALSE;
io_remove(&pump->io);
/* flush it */
switch (o_stream_flush(pump->output)) {
pump->callback(FALSE, pump->context);
break;
case 0:
+ pump->waiting_output = TRUE;
pump->completed = TRUE;
break;
default:
}
return;
case OSTREAM_SEND_ISTREAM_RESULT_WAIT_INPUT:
+ pump->waiting_output = FALSE;
return;
}
i_unreached();
pump->callback(FALSE, pump->context);
return ret;
}
+ pump->waiting_output = FALSE;
if (pump->completed) {
pump->callback(TRUE, pump->context);
return 1;
io_remove(&pump->io);
}
+bool iostream_pump_is_waiting_output(struct iostream_pump *pump)
+{
+ return pump->waiting_output;
+}
+
void iostream_pump_switch_ioloop(struct iostream_pump *pump)
{
i_assert(pump != NULL);
iostream_pump_set_completion_callback(pump, (iostream_pump_callback_t *)callback, context + \
CALLBACK_TYPECHECK(callback, void (*)(bool, typeof(context))))
+/* Returns TRUE if the pump is currently only writing to the ostream. The input
+ listener has been removed either because the ostream buffer is full or
+ because the istream already returned EOF. This function can also be called
+ from the completion callback in error conditions. */
+bool iostream_pump_is_waiting_output(struct iostream_pump *pump);
+
void iostream_pump_switch_ioloop(struct iostream_pump *pump);
#endif