diff --git a/src/Dispatcher.cpp b/src/Dispatcher.cpp index 7700204cb0..060f2d17f6 100644 --- a/src/Dispatcher.cpp +++ b/src/Dispatcher.cpp @@ -232,14 +232,15 @@ void DispatcherBase::DispatchThreadMain() { if (err) WARNING("periodic persistent save: " << err); } - if (++count > 10) { - DEBUG("dispatch running"); - count = 0; - } - { std::lock_guard user_lock(m_user_mutex); bool reconnect = false; + + if (++count > 10) { + DEBUG("dispatch running " << m_connections.size() << " connections"); + count = 0; + } + for (auto& conn : m_connections) { // post outgoing messages if connection is active // only send keep-alives on client @@ -458,6 +459,7 @@ bool DispatcherBase::ServerHandshake( if (proto_rev >= 0x0300) conn.set_remote_id(msg->str()); // Set the proto version to the client requested version + DEBUG("server: client protocol " << proto_rev); conn.set_proto_rev(proto_rev); // Send initial set of assignments diff --git a/src/Message.cpp b/src/Message.cpp index c8828f6a21..3255c3c046 100644 --- a/src/Message.cpp +++ b/src/Message.cpp @@ -7,6 +7,7 @@ #include "Message.h" +#include "Log.h" #include "WireDecoder.h" #include "WireEncoder.h" @@ -79,8 +80,10 @@ std::shared_ptr Message::Read(WireDecoder& decoder, unsigned int itype; if (!decoder.Read8(&itype)) return nullptr; type = static_cast(itype); - } else + } else { type = get_entry_type(msg->m_id); + DEBUG4("update message data type: " << type); + } msg->m_value = decoder.ReadValue(type); if (!msg->m_value) return nullptr; break; @@ -146,6 +149,7 @@ std::shared_ptr Message::Read(WireDecoder& decoder, } default: decoder.set_error("unrecognized message type"); + INFO("unrecognized message type: " << msg_type); return nullptr; } return msg; diff --git a/src/NetworkConnection.cpp b/src/NetworkConnection.cpp index 96286a572b..c6f2e77f99 100644 --- a/src/NetworkConnection.cpp +++ b/src/NetworkConnection.cpp @@ -54,6 +54,7 @@ void NetworkConnection::Start() { } void NetworkConnection::Stop() { + DEBUG2("NetworkConnection stopping (" << this << ")"); m_state = static_cast(kDead); m_active = false; // closing the stream so the read thread terminates @@ -131,6 +132,7 @@ void NetworkConnection::ReadThreadMain() { decoder.Reset(); auto msg = Message::Read(decoder, m_get_entry_type); if (!msg) { + INFO("read error: " << decoder.error()); // terminate connection on bad message if (m_stream) m_stream->close(); break; @@ -141,7 +143,7 @@ void NetworkConnection::ReadThreadMain() { m_last_update = Now(); m_process_incoming(std::move(msg), this); } - DEBUG3("read thread died"); + DEBUG3("read thread died (" << this << ")"); if (m_state != kDead) m_notifier.NotifyConnection(false, info()); m_state = static_cast(kDead); m_active = false; @@ -180,7 +182,7 @@ void NetworkConnection::WriteThreadMain() { if (m_stream->send(encoder.data(), encoder.size(), &err) == 0) break; DEBUG4("sent " << encoder.size() << " bytes"); } - DEBUG3("write thread died"); + DEBUG3("write thread died (" << this << ")"); if (m_state != kDead) m_notifier.NotifyConnection(false, info()); m_state = static_cast(kDead); m_active = false;