return bytes_sent != 0 ? (ssize_t)bytes_sent : ret;
}
+static void o_stream_ssl_switch_ioloop(struct ostream_private *stream)
+{
+ struct ssl_ostream *sstream = (struct ssl_ostream *)stream;
+
+ o_stream_switch_ioloop(sstream->ssl_io->plain_output);
+}
+
static int plain_flush_callback(struct ssl_ostream *sstream)
{
int ret, ret2;
sstream->ostream.iostream.destroy = o_stream_ssl_destroy;
sstream->ostream.sendv = o_stream_ssl_sendv;
sstream->ostream.flush = o_stream_ssl_flush;
+ sstream->ostream.switch_ioloop = o_stream_ssl_switch_ioloop;
o_stream_set_flush_callback(ssl_io->plain_output,
plain_flush_callback, sstream);
return io_stream_copy_stream(outstream, instream, same_stream);
}
+static void o_stream_file_switch_ioloop(struct ostream_private *stream)
+{
+ struct file_ostream *fstream = (struct file_ostream *)stream;
+
+ if (fstream->io != NULL)
+ fstream->io = io_loop_move_io(&fstream->io);
+}
+
static struct file_ostream *
o_stream_create_fd_common(int fd, bool autoclose_fd)
{
fstream->ostream.sendv = o_stream_file_sendv;
fstream->ostream.write_at = o_stream_file_write_at;
fstream->ostream.send_istream = o_stream_file_send_istream;
+ fstream->ostream.switch_ioloop = o_stream_file_switch_ioloop;
return fstream;
}
const void *data, size_t size, uoff_t offset);
off_t (*send_istream)(struct ostream_private *outstream,
struct istream *instream);
+ void (*switch_ioloop)(struct ostream_private *stream);
/* data: */
struct ostream ostream;
return (off_t)(instream->v_offset - start_offset);
}
+
+void o_stream_switch_ioloop(struct ostream *stream)
+{
+ struct ostream_private *_stream = stream->real_stream;
+
+ if (_stream->switch_ioloop != NULL)
+ _stream->switch_ioloop(_stream);
+}
int o_stream_pwrite(struct ostream *stream, const void *data, size_t size,
uoff_t offset);
+/* If there are any I/O loop items associated with the stream, move all of
+ them to current_ioloop. */
+void o_stream_switch_ioloop(struct ostream *stream);
+
#endif
return ret;
}
+static void o_stream_bzlib_switch_ioloop(struct ostream_private *stream)
+{
+ struct bzlib_ostream *zstream = (struct bzlib_ostream *)stream;
+
+ o_stream_switch_ioloop(zstream->output);
+}
+
static ssize_t
o_stream_bzlib_sendv(struct ostream_private *stream,
const struct const_iovec *iov, unsigned int iov_count)
zstream->ostream.sendv = o_stream_bzlib_sendv;
zstream->ostream.cork = o_stream_bzlib_cork;
zstream->ostream.flush = o_stream_bzlib_flush;
+ zstream->ostream.switch_ioloop = o_stream_bzlib_switch_ioloop;
zstream->ostream.iostream.close = o_stream_bzlib_close;
zstream->output = output;
o_stream_ref(output);
return ret;
}
+static void o_stream_zlib_switch_ioloop(struct ostream_private *stream)
+{
+ struct zlib_ostream *zstream = (struct zlib_ostream *)stream;
+
+ o_stream_switch_ioloop(zstream->output);
+}
+
static ssize_t
o_stream_zlib_sendv(struct ostream_private *stream,
const struct const_iovec *iov, unsigned int iov_count)
zstream->ostream.sendv = o_stream_zlib_sendv;
zstream->ostream.cork = o_stream_zlib_cork;
zstream->ostream.flush = o_stream_zlib_flush;
+ zstream->ostream.switch_ioloop = o_stream_zlib_switch_ioloop;
zstream->ostream.iostream.close = o_stream_zlib_close;
zstream->output = output;
zstream->crc = 0;