]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-ssl-iostream: Do not handshake further if we are destroying
authorAki Tuomi <aki.tuomi@dovecot.fi>
Tue, 17 Apr 2018 12:58:58 +0000 (15:58 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Mon, 4 Jun 2018 09:30:40 +0000 (12:30 +0300)
src/lib-ssl-iostream/iostream-openssl.c
src/lib-ssl-iostream/iostream-openssl.h

index a8ce19ad41183867382fbf8be4b48e2e56b5f956..d1459d40692d602e9bec4bb5e29431375caaae99 100644 (file)
@@ -344,6 +344,7 @@ static void openssl_iostream_unref(struct ssl_iostream *ssl_io)
 
 static void openssl_iostream_destroy(struct ssl_iostream *ssl_io)
 {
+       ssl_io->destroyed = TRUE;
        if (ssl_io->handshaked && SSL_shutdown(ssl_io->ssl) != 1) {
                /* if bidirectional shutdown fails we need to clear
                   the error queue */
@@ -628,6 +629,10 @@ static int openssl_iostream_handshake(struct ssl_iostream *ssl_io)
 
        i_assert(!ssl_io->handshaked);
 
+       /* we are being destroyed, so do not do any more handshaking */
+       if (ssl_io->destroyed)
+               return 0;
+
        if (ssl_io->ctx->client_ctx) {
                while ((ret = SSL_connect(ssl_io->ssl)) <= 0) {
                        ret = openssl_iostream_handle_error(ssl_io, ret,
index 9cefe2d0e96ae49d1640ca06080ddd04c8e7e161..ca34fae62387ef0543ab369d6c5769a91c0a6623 100644 (file)
@@ -66,6 +66,7 @@ struct ssl_iostream {
        bool want_read:1;
        bool ostream_flush_waiting_input:1;
        bool closed:1;
+       bool destroyed:1;
 };
 
 extern int dovecot_ssl_extdata_index;