diff --git a/server/red-stream.c b/server/red-stream.c index bdc8bc1f..9a9c1a0f 100644 --- a/server/red-stream.c +++ b/server/red-stream.c @@ -203,6 +203,15 @@ bool red_stream_write_all(RedStream *stream, const void *in_buf, size_t n) return true; } +bool red_stream_set_auto_flush(RedStream *s, bool auto_flush) +{ + return auto_flush; +} + +void red_stream_flush(RedStream *s) +{ +} + #if HAVE_SASL static ssize_t red_stream_sasl_write(RedStream *s, const void *buf, size_t nbyte); #endif diff --git a/server/red-stream.h b/server/red-stream.h index 4d5075ed..15af0a59 100644 --- a/server/red-stream.h +++ b/server/red-stream.h @@ -69,6 +69,26 @@ bool red_stream_set_no_delay(RedStream *stream, bool no_delay); int red_stream_get_no_delay(RedStream *stream); int red_stream_send_msgfd(RedStream *stream, int fd); +/** + * Set auto flush flag. + * If set, stream will send data to the underlying socket as + * soon as data are written. This is the default. + * If not set, you should call red_stream_flush to force + * data to be sent. Failing to call red_stream_flush on a + * manual flush stream could lead to latency. + * Disabling auto flush can fail while enabling cannot. + * + * Returns true on success or false on failure. + */ +bool red_stream_set_auto_flush(RedStream *stream, bool auto_flush); + +/** + * Flush data to the underlying socket. + * Calling this function on a stream with auto flush set has + * no result. + */ +void red_stream_flush(RedStream *stream); + typedef enum { RED_SASL_ERROR_OK, RED_SASL_ERROR_GENERIC,