From b57c855a8c4a1c2a2278bf8e25ba6b82697387cd Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Mon, 9 Nov 2015 10:25:20 -0800 Subject: PROXY_SEND fix. --- node/Cluster.cpp | 13 ++++++++----- node/Cluster.hpp | 4 ++-- one.o-2f9cf2a3 | 0 3 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 one.o-2f9cf2a3 diff --git a/node/Cluster.cpp b/node/Cluster.cpp index ac8017ca..7244c951 100644 --- a/node/Cluster.cpp +++ b/node/Cluster.cpp @@ -308,7 +308,6 @@ void Cluster::handleIncomingStateMessage(const void *msg,unsigned int len) Buffer<2048> rendezvousForRemote; remotePeerAddress.appendTo(rendezvousForRemote); rendezvousForRemote.append((uint8_t)Packet::VERB_RENDEZVOUS); - const unsigned int rendezvousForOtherEndPayloadSizePtr = rendezvousForRemote.size(); rendezvousForRemote.addSize(2); // space for actual packet payload length rendezvousForRemote.append((uint8_t)0); // flags == 0 localPeerAddress.appendTo(rendezvousForRemote); @@ -324,7 +323,7 @@ void Cluster::handleIncomingStateMessage(const void *msg,unsigned int len) rendezvousForRemote.append((uint16_t)bestLocalV6.port()); rendezvousForRemote.append((uint8_t)16); rendezvousForRemote.append(bestLocalV6.rawIpData(),16); - rendezvousForRemote.setAt(rendezvousForOtherEndPayloadSizePtr,(uint16_t)(9 + 16)); + rendezvousForRemote.setAt(ZT_ADDRESS_LENGTH + 1,(uint16_t)(9 + 16)); } else if ((bestLocalV4)&&(bestRemoteV4)) { haveMatch = true; @@ -335,7 +334,7 @@ void Cluster::handleIncomingStateMessage(const void *msg,unsigned int len) rendezvousForRemote.append((uint16_t)bestLocalV4.port()); rendezvousForRemote.append((uint8_t)4); rendezvousForRemote.append(bestLocalV4.rawIpData(),4); - rendezvousForRemote.setAt(rendezvousForOtherEndPayloadSizePtr,(uint16_t)(9 + 4)); + rendezvousForRemote.setAt(ZT_ADDRESS_LENGTH + 1,(uint16_t)(9 + 4)); } if (haveMatch) { @@ -749,11 +748,13 @@ void Cluster::_doREMOTE_WHOIS(uint64_t fromMemberId,const Packet &remotep) Buffer<1024> routp; remotep.source().appendTo(routp); routp.append((uint8_t)Packet::VERB_OK); + routp.addSize(2); // space for length routp.append((uint8_t)Packet::VERB_WHOIS); routp.append(remotep.packetId()); queried.serialize(routp); Mutex::Lock _l2(_members[fromMemberId].lock); + routp.setAt(ZT_ADDRESS_LENGTH + 1,(uint16_t)(routp.size() - ZT_ADDRESS_LENGTH - 3)); _send(fromMemberId,CLUSTER_MESSAGE_PROXY_SEND,routp.data(),routp.size()); _flush(fromMemberId); } @@ -771,15 +772,17 @@ void Cluster::_doREMOTE_MULTICAST_GATHER(uint64_t fromMemberId,const Packet &rem Buffer routp; remotePeerAddress.appendTo(routp); routp.append((uint8_t)Packet::VERB_OK); + routp.addSize(2); // space for length routp.append((uint8_t)Packet::VERB_MULTICAST_GATHER); routp.append(remotep.packetId()); routp.append(nwid); mg.mac().appendTo(routp); routp.append((uint32_t)mg.adi()); - if (gatherLimit > ((ZT_CLUSTER_MAX_MESSAGE_LENGTH - 64) / 5)) - gatherLimit = ((ZT_CLUSTER_MAX_MESSAGE_LENGTH - 64) / 5); + if (gatherLimit > ((ZT_CLUSTER_MAX_MESSAGE_LENGTH - 80) / 5)) + gatherLimit = ((ZT_CLUSTER_MAX_MESSAGE_LENGTH - 80) / 5); if (RR->mc->gather(remotePeerAddress,nwid,mg,routp,gatherLimit)) { + routp.setAt(ZT_ADDRESS_LENGTH + 1,(uint16_t)(routp.size() - ZT_ADDRESS_LENGTH - 3)); Mutex::Lock _l2(_members[fromMemberId].lock); _send(fromMemberId,CLUSTER_MESSAGE_PROXY_SEND,routp.data(),routp.size()); } diff --git a/node/Cluster.hpp b/node/Cluster.hpp index e45b2d82..beb5ecdc 100644 --- a/node/Cluster.hpp +++ b/node/Cluster.hpp @@ -58,12 +58,12 @@ /** * Desired period between doPeriodicTasks() in milliseconds */ -#define ZT_CLUSTER_PERIODIC_TASK_PERIOD 250 +#define ZT_CLUSTER_PERIODIC_TASK_PERIOD 100 /** * How often to flush outgoing message queues (maximum interval) */ -#define ZT_CLUSTER_FLUSH_PERIOD 500 +#define ZT_CLUSTER_FLUSH_PERIOD 300 /** * Maximum number of queued outgoing packets per sender address diff --git a/one.o-2f9cf2a3 b/one.o-2f9cf2a3 new file mode 100644 index 00000000..e69de29b -- cgit v1.2.3