If the SSL_shutdown-call fails (e.g. because the underlaying socket has
already been closed) OpenSSL puts the corresponding error into the
queue. We don't care about details so we need to clear the queue.
Otherwise the error will be pulled while error checking the next OpenSSL
call of an unrelated connection.
static void openssl_iostream_destroy(struct ssl_iostream *ssl_io)
{
- (void)SSL_shutdown(ssl_io->ssl);
+ if (SSL_shutdown(ssl_io->ssl) != 1) {
+ /* if bidirectional shutdown fails we need to clear
+ the error queue */
+ openssl_iostream_clear_errors();
+ }
(void)openssl_iostream_more(ssl_io);
(void)o_stream_flush(ssl_io->plain_output);
/* close the plain i/o streams, because their fd may be closed soon,
if (proxy->io_plain_write != NULL)
io_remove(&proxy->io_plain_write);
- (void)SSL_shutdown(proxy->ssl);
+ if (SSL_shutdown(proxy->ssl) != 1) {
+ /* if bidirectional shutdown fails we need to clear
+ the error queue. */
+ openssl_iostream_clear_errors();
+ }
net_disconnect(proxy->fd_ssl);
net_disconnect(proxy->fd_plain);