struct ostream_private ostream;
struct ssl_iostream *ssl_io;
buffer_t *buffer;
+
+ bool shutdown:1;
};
static void
size_t pos = 0;
int ret = 1;
+ i_assert(!sstream->shutdown);
+
while (pos < sstream->buffer->used) {
/* we're writing plaintext data to OpenSSL, which it encrypts
and writes to bio_int's buffer. ssl_iostream_bio_sync()
ret = o_stream_ssl_flush_buffer(sstream);
}
+ /* Stream is finished; shutdown the SSL write direction once our buffer
+ is empty. */
+ if (stream->finished && !sstream->shutdown && ret >= 0 &&
+ (sstream->buffer == NULL || sstream->buffer->used == 0)) {
+ sstream->shutdown = TRUE;
+ if (SSL_shutdown(ssl_io->ssl) < 0) {
+ io_stream_set_error(
+ &sstream->ostream.iostream, "%s",
+ t_strdup_printf("SSL_shutdown() failed: %s",
+ openssl_iostream_error()));
+ sstream->ostream.ostream.stream_errno = EIO;
+ ret = -1;
+ }
+ }
+
if (ret == 0 && ssl_io->want_read) {
/* we need to read more data until we can continue. */
o_stream_set_flush_pending(plain_output, FALSE);
struct ssl_ostream *sstream = (struct ssl_ostream *)stream;
size_t bytes_sent = 0;
+ i_assert(!sstream->shutdown);
+
bytes_sent = o_stream_ssl_buffer(sstream, iov, iov_count, bytes_sent);
if (sstream->ssl_io->handshaked &&
sstream->buffer->used == bytes_sent) {