From 1c55fb0409245144264e0f68c01910b5c7506410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Tue, 13 Mar 2018 18:15:04 +0100 Subject: [PATCH] Properly handle TLS disconnects in OpenSSLStream.leastSize. Fixes bogus "Reading from TLS stream was unsuccessful with ret 0" errors. --- tls/vibe/stream/openssl.d | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tls/vibe/stream/openssl.d b/tls/vibe/stream/openssl.d index 2d86f8d947..cddb0df5a7 100644 --- a/tls/vibe/stream/openssl.d +++ b/tls/vibe/stream/openssl.d @@ -241,7 +241,9 @@ final class OpenSSLStream : TLSStream { @property ulong leastSize() { - checkSSLRet(() @trusted { return SSL_peek(m_tls, m_peekBuffer.ptr, 1); } (), "Reading from TLS stream"); + auto ret = () @trusted { return SSL_peek(m_tls, m_peekBuffer.ptr, 1); } (); + if (ret != 0) // zero means the connection got closed + checkSSLRet(ret, "Peeking TLS stream"); return () @trusted { return SSL_pending(m_tls); } (); }