#include "ioloop.h"
#include "array.h"
#include "str.h"
+#include "fd-set-nonblock.h"
#include "istream-private.h"
static bool i_stream_is_buffer_invalid(const struct istream_private *stream);
} while (stream != NULL);
}
+void i_stream_set_blocking(struct istream *stream, bool blocking)
+{
+ int prev_fd = -1;
+
+ do {
+ stream->blocking = blocking;
+ if (stream->real_stream->fd != -1 &&
+ stream->real_stream->fd != prev_fd) {
+ fd_set_nonblock(stream->real_stream->fd, !blocking);
+ prev_fd = stream->real_stream->fd;
+ }
+ stream = stream->real_stream->parent;
+ } while (stream != NULL);
+}
+
static void i_stream_update(struct istream_private *stream)
{
if (stream->parent == NULL)
the memory usage is minimized by freeing the stream's buffers whenever they
become empty. */
void i_stream_set_persistent_buffers(struct istream *stream, bool set);
+/* Set the istream blocking or nonblocking, including its parent streams.
+ If any of the istreams have an fd, its O_NONBLOCK flag is changed. */
+void i_stream_set_blocking(struct istream *stream, bool blocking);
/* Returns number of bytes read if read was ok, -1 if EOF or error, -2 if the
input buffer is full. */