]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-ssl-iostream: When SSL i/ostream is closed, close also the plain stream.
authorTimo Sirainen <tss@iki.fi>
Wed, 7 Sep 2011 07:24:11 +0000 (10:24 +0300)
committerTimo Sirainen <tss@iki.fi>
Wed, 7 Sep 2011 07:24:11 +0000 (10:24 +0300)
src/lib-ssl-iostream/istream-openssl.c
src/lib-ssl-iostream/ostream-openssl.c

index a5ca4330cfdd54ea14212cbd6cdda08d929787f5..196831f89c3074f5ff0ab1920f1fb8193f179fce 100644 (file)
@@ -10,6 +10,13 @@ struct ssl_istream {
        bool seen_eof;
 };
 
+static void i_stream_ssl_close(struct iostream_private *stream)
+{
+       struct ssl_istream *sstream = (struct ssl_istream *)stream;
+
+       i_stream_close(sstream->ssl_io->plain_input);
+}
+
 static void i_stream_ssl_destroy(struct iostream_private *stream)
 {
        struct ssl_istream *sstream = (struct ssl_istream *)stream;
@@ -66,6 +73,7 @@ struct istream *i_stream_create_ssl(struct ssl_iostream *ssl_io)
 
        sstream = i_new(struct ssl_istream, 1);
        sstream->ssl_io = ssl_io;
+       sstream->istream.iostream.close = i_stream_ssl_close;
        sstream->istream.iostream.destroy = i_stream_ssl_destroy;
        sstream->istream.max_buffer_size =
                ssl_io->plain_input->real_stream->max_buffer_size;
index 6f81df6ac7dac9157dd80fed4c91191a254b7efb..a3c79ce25405b71f7824bb8d71463c00f151356c 100644 (file)
@@ -11,7 +11,14 @@ struct ssl_ostream {
        buffer_t *buffer;
 };
 
-static void i_stream_ssl_destroy(struct iostream_private *stream)
+static void o_stream_ssl_close(struct iostream_private *stream)
+{
+       struct ssl_ostream *sstream = (struct ssl_ostream *)stream;
+
+       o_stream_close(sstream->ssl_io->plain_output);
+}
+
+static void o_stream_ssl_destroy(struct iostream_private *stream)
 {
        struct ssl_ostream *sstream = (struct ssl_ostream *)stream;
 
@@ -198,7 +205,8 @@ struct ostream *o_stream_create_ssl(struct ssl_iostream *ssl_io)
        sstream->ssl_io = ssl_io;
        sstream->ostream.max_buffer_size =
                ssl_io->plain_output->real_stream->max_buffer_size;
-       sstream->ostream.iostream.destroy = i_stream_ssl_destroy;
+       sstream->ostream.iostream.close = o_stream_ssl_close;
+       sstream->ostream.iostream.destroy = o_stream_ssl_destroy;
        sstream->ostream.sendv = o_stream_ssl_sendv;
        sstream->ostream.flush = o_stream_ssl_flush;