From e8f6540b4ba1bdaf61622f09e1b40520954ec576 Mon Sep 17 00:00:00 2001 From: Steven Date: Thu, 11 Aug 2022 10:56:49 +0200 Subject: [PATCH] also push to queue if connectInProgress. --- src/clientpaho.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/clientpaho.cpp b/src/clientpaho.cpp index 1dcbf6a..af197c8 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 || m_processPendingPublishes ) + if( ConnectionStatus::ReconnectInProgress == m_connectionStatus || ConnectionStatus::ConnectInProgress == m_connectionStatus || m_processPendingPublishes ) { m_pendingPublishesReadyCV.wait(lck, [this]() { return !m_processPendingPublishes; }); - if( ConnectionStatus::ReconnectInProgress == m_connectionStatus ) + if( ConnectionStatus::ReconnectInProgress == m_connectionStatus || ConnectionStatus::ConnectInProgress == m_connectionStatus ) { LogDebug( "[ClientPaho::publish]", "Adding publish to pending queue." ); m_pendingPublishes.push_front( Publish{ qos, message } ); @@ -1127,7 +1127,8 @@ 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->onConnectSuccessOnInstance(); } ); + cl->pushIncomingEvent( [cl, reason]() { cl->onConnectOnInstance( reason ); } ); } } -- libgit2 0.21.4