Skip to content

Commit

Permalink
Merge pull request #805 from paullouisageneau/fix-gnutls-tls-readcall…
Browse files Browse the repository at this point in the history
…back

Fix TLS pull timeout function for GnuTLS
  • Loading branch information
paullouisageneau authored Feb 15, 2023
2 parents 4df86b6 + b0def28 commit 5ed1bc7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/impl/tlstransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<TlsTransport *>(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;
Expand Down

0 comments on commit 5ed1bc7

Please sign in to comment.