From 75d89349611bb37e46655c2918b5826023904be7 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 17 Oct 2013 16:46:49 -0700 Subject: [PATCH] fix pinging of agents in broadcast to nodes --- libraries/shared/src/NodeList.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libraries/shared/src/NodeList.cpp b/libraries/shared/src/NodeList.cpp index 6510276f9a..8d8d48dcdc 100644 --- a/libraries/shared/src/NodeList.cpp +++ b/libraries/shared/src/NodeList.cpp @@ -601,6 +601,7 @@ void NodeList::pingPublicAndLocalSocketsForInactiveNode(Node* node) const { currentTime = usecTimestampNow(); memcpy(pingPacket + numHeaderBytes, ¤tTime, sizeof(currentTime)); + qDebug() << "Attemping to ping" << *node << "\n"; // send the ping packet to the local and public sockets for this node _nodeSocket.send(node->getLocalSocket(), pingPacket, sizeof(pingPacket)); _nodeSocket.send(node->getPublicSocket(), pingPacket, sizeof(pingPacket)); @@ -657,15 +658,15 @@ unsigned NodeList::broadcastToNodes(unsigned char* broadcastData, size_t dataByt unsigned n = 0; for(NodeList::iterator node = begin(); node != end(); node++) { // only send to the NodeTypes we are asked to send to. - if (node->getActiveSocket() != NULL) { - if (memchr(nodeTypes, node->getType(), numNodeTypes)) { + if (memchr(nodeTypes, node->getType(), numNodeTypes)) { + if (node->getActiveSocket()) { // we know which socket is good for this node, send there _nodeSocket.send(node->getActiveSocket(), broadcastData, dataBytes); ++n; + } else { + // we don't have an active link to this node, ping it to set that up + pingPublicAndLocalSocketsForInactiveNode(&(*node)); } - } else { - // we don't have an active link to this node, ping it to set that up - pingPublicAndLocalSocketsForInactiveNode(&(*node)); } } return n;