Commit e8f6540b4ba1bdaf61622f09e1b40520954ec576

Authored by Steven
1 parent 1ffaa75b

also push to queue if connectInProgress.

Queue is only correctly unloaded in onConnect. it does not seem to be
unloaded on onFirstConnect, only when changing pushIncomingEvent. should
investigate.
Showing 1 changed file with 4 additions and 3 deletions
src/clientpaho.cpp
... ... @@ -377,10 +377,10 @@ std::int32_t ClientPaho::publish( const MqttMessage& message, int qos )
377 377 }
378 378  
379 379 std::unique_lock<std::mutex> lck(m_mutex);
380   - if( ConnectionStatus::ReconnectInProgress == m_connectionStatus || m_processPendingPublishes )
  380 + if( ConnectionStatus::ReconnectInProgress == m_connectionStatus || ConnectionStatus::ConnectInProgress == m_connectionStatus || m_processPendingPublishes )
381 381 {
382 382 m_pendingPublishesReadyCV.wait(lck, [this]() { return !m_processPendingPublishes; });
383   - if( ConnectionStatus::ReconnectInProgress == m_connectionStatus )
  383 + if( ConnectionStatus::ReconnectInProgress == m_connectionStatus || ConnectionStatus::ConnectInProgress == m_connectionStatus )
384 384 {
385 385 LogDebug( "[ClientPaho::publish]", "Adding publish to pending queue." );
386 386 m_pendingPublishes.push_front( Publish{ qos, message } );
... ... @@ -1127,7 +1127,8 @@ void ClientPaho::onFirstConnect( void* context, char* cause )
1127 1127 {
1128 1128 auto *cl = reinterpret_cast<ClientPaho*>( context );
1129 1129 std::string reason( nullptr == cause ? "Unknown cause" : cause );
1130   - cl->pushIncomingEvent( [cl, reason]() { cl->onConnectSuccessOnInstance(); } );
  1130 + //cl->pushIncomingEvent( [cl, reason]() { cl->onConnectSuccessOnInstance(); } );
  1131 + cl->pushIncomingEvent( [cl, reason]() { cl->onConnectOnInstance( reason ); } );
1131 1132 }
1132 1133 }
1133 1134  
... ...