]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: iostream: Record the ioloop that the iostream was last switched to.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Wed, 24 Jan 2018 22:02:03 +0000 (23:02 +0100)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Mon, 12 Mar 2018 07:22:59 +0000 (09:22 +0200)
src/lib/iostream-private.h
src/lib/iostream.c
src/lib/istream.c
src/lib/ostream.c

index d56fcf43b105efee3dde2d85cee660de49c8a6cf..9aa72e9b925c2f13b16d1e40babe866043c4e313 100644 (file)
@@ -14,6 +14,7 @@ struct iostream_private {
        int refcount;
        char *name;
        char *error;
+       struct ioloop *ioloop;
 
        void (*close)(struct iostream_private *streami, bool close_parent);
        void (*destroy)(struct iostream_private *stream);
@@ -43,4 +44,8 @@ void io_stream_set_error(struct iostream_private *stream,
 void io_stream_set_verror(struct iostream_private *stream,
                          const char *fmt, va_list args) ATTR_FORMAT(2, 0);
 
+void io_stream_switch_ioloop_to(struct iostream_private *stream,
+                               struct ioloop *ioloop);
+struct ioloop *io_stream_get_ioloop(struct iostream_private *stream);
+
 #endif
index bdf139adca0206262addfdb0d3619636d8576b18..f2ba00088d2465c0b235a81c786e375115c1b57f 100644 (file)
@@ -23,6 +23,7 @@ void io_stream_init(struct iostream_private *stream)
                stream->close = io_stream_default_close;
        if (stream->destroy == NULL)
                stream->destroy = io_stream_default_destroy;
+       stream->ioloop = current_ioloop;
 
        stream->refcount = 1;
 }
@@ -140,3 +141,14 @@ const char *io_stream_get_disconnect_reason(struct istream *input,
        else
                return t_strdup_printf("Connection closed: %s", errstr);
 }
+
+void io_stream_switch_ioloop_to(struct iostream_private *stream,
+                               struct ioloop *ioloop)
+{
+       stream->ioloop = ioloop;
+}
+
+struct ioloop *io_stream_get_ioloop(struct iostream_private *stream)
+{
+       return (stream->ioloop == NULL ? current_ioloop : stream->ioloop);
+}
index d1c3f99fd657c905aa1ebdd33777f15b50e1b98a..1486f24dbf6b858a9a17d8aabc6300e412def8ee 100644 (file)
@@ -928,6 +928,9 @@ void i_stream_set_input_pending(struct istream *stream, bool pending)
 
 void i_stream_switch_ioloop(struct istream *stream)
 {
+       io_stream_switch_ioloop_to(&stream->real_stream->iostream,
+                                  current_ioloop);
+
        do {
                if (stream->real_stream->switch_ioloop != NULL)
                        stream->real_stream->switch_ioloop(stream->real_stream);
index 23a68582b7b2203b14ea9e76c1abb87bb7e327bd..7004d858ea79b24400a34a72ee6daca823cbc66b 100644 (file)
@@ -503,6 +503,8 @@ void o_stream_switch_ioloop(struct ostream *stream)
 {
        struct ostream_private *_stream = stream->real_stream;
 
+       io_stream_switch_ioloop_to(&_stream->iostream, current_ioloop);
+
        _stream->switch_ioloop(_stream);
 }