From b0def28f95be4683fb976f62c3ea886294f582d8 Mon Sep 17 00:00:00 2001 From: Paul-Louis Ageneau Date: Wed, 15 Feb 2023 13:24:01 +0100 Subject: [PATCH] Fixed TlsTransport::TimeoutCallback() for GnuTLS --- src/impl/tlstransport.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/impl/tlstransport.cpp b/src/impl/tlstransport.cpp index 90b4ee649..beb09472c 100644 --- a/src/impl/tlstransport.cpp +++ b/src/impl/tlstransport.cpp @@ -266,6 +266,12 @@ ssize_t TlsTransport::ReadCallback(gnutls_transport_ptr_t ptr, void *data, size_ int TlsTransport::TimeoutCallback(gnutls_transport_ptr_t ptr, unsigned int ms) { TlsTransport *t = static_cast(ptr); try { + message_ptr &message = t->mIncomingMessage; + size_t &position = t->mIncomingMessagePosition; + + if(message && position < message->size()) + return 1; + bool isReadable = t->mIncomingQueue.wait( ms != GNUTLS_INDEFINITE_TIMEOUT ? std::make_optional(milliseconds(ms)) : nullopt); return isReadable ? 1 : 0;