From 7b8c2652e127f1a2465b3de229c19fcae9d5c10b Mon Sep 17 00:00:00 2001 From: Jake Smith Date: Wed, 3 Apr 2024 11:43:15 +0100 Subject: [PATCH] HPCC-31474 modify secure set_nonblock impl. Signed-off-by: Jake Smith --- system/security/securesocket/securesocket.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/system/security/securesocket/securesocket.cpp b/system/security/securesocket/securesocket.cpp index 81ab011b49a..551057b73d8 100644 --- a/system/security/securesocket/securesocket.cpp +++ b/system/security/securesocket/securesocket.cpp @@ -246,11 +246,13 @@ class CSecureSocket : implements ISecureSocket, public CInterface // virtual bool set_nonblock(bool on) // returns old state { - bool prevState = m_socket->set_nonblock(on); - int flags = fcntl(SSL_get_fd(m_ssl), F_GETFL, 0); - if (-1 != flags) - nonBlocking = 0 != (flags & O_NONBLOCK); - return prevState; + if (on == nonBlocking) + return nonBlocking; + if (on == m_socket->set_nonblock(on)) // this call should return opposite state, if it doesn't it failed + return nonBlocking; + + nonBlocking = on; + return !nonBlocking; // previous state } // enable 'nagling' - small packet coalescing (implies delayed transmission)