From 9802eeb999f20453995f7d4d7f6ed92e197539be Mon Sep 17 00:00:00 2001 From: Steven Date: Thu, 11 Aug 2022 13:44:30 +0200 Subject: [PATCH] statement changes --- src/clientpaho.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/clientpaho.cpp b/src/clientpaho.cpp index af197c8..9b492c3 100644 --- a/src/clientpaho.cpp +++ b/src/clientpaho.cpp @@ -377,10 +377,10 @@ std::int32_t ClientPaho::publish( const MqttMessage& message, int qos ) } std::unique_lock lck(m_mutex); - if( ConnectionStatus::ReconnectInProgress == m_connectionStatus || ConnectionStatus::ConnectInProgress == m_connectionStatus || m_processPendingPublishes ) + if( ConnectionStatus::Connected != m_connectionStatus || m_processPendingPublishes ) { m_pendingPublishesReadyCV.wait(lck, [this]() { return !m_processPendingPublishes; }); - if( ConnectionStatus::ReconnectInProgress == m_connectionStatus || ConnectionStatus::ConnectInProgress == m_connectionStatus ) + if( ConnectionStatus::Connected != m_connectionStatus ) { LogDebug( "[ClientPaho::publish]", "Adding publish to pending queue." ); m_pendingPublishes.push_front( Publish{ qos, message } ); @@ -789,6 +789,8 @@ void ClientPaho::onConnectOnInstance( const std::string& cause ) void ClientPaho::onConnectSuccessOnInstance() { + m_processPendingPublishes = true; + LogDebug( "[ClientPaho::onConnectSuccessOnInstance]", std::string( m_clientId + " - onConnectSuccessOnInstance triggered." ) ); { @@ -1127,8 +1129,7 @@ void ClientPaho::onFirstConnect( void* context, char* cause ) { auto *cl = reinterpret_cast( context ); std::string reason( nullptr == cause ? "Unknown cause" : cause ); - //cl->pushIncomingEvent( [cl, reason]() { cl->onConnectSuccessOnInstance(); } ); - cl->pushIncomingEvent( [cl, reason]() { cl->onConnectOnInstance( reason ); } ); + cl->pushIncomingEvent( [cl, reason]() { cl->onConnectSuccessOnInstance(); } ); } } -- libgit2 0.21.4