mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 03:53:44 +02:00
Small additional efficiency improvement.
This commit is contained in:
parent
59ba7c8bf5
commit
723a9a6e9a
1 changed files with 13 additions and 5 deletions
|
@ -52,8 +52,18 @@ void Membership::pushCredentials(const RuntimeEnvironment *RR,const uint64_t now
|
||||||
} else sendCap = (const Capability *)0;
|
} else sendCap = (const Capability *)0;
|
||||||
} else sendCap = (const Capability *)0;
|
} else sendCap = (const Capability *)0;
|
||||||
|
|
||||||
|
const Tag *sendTags[ZT_MAX_NETWORK_TAGS];
|
||||||
|
unsigned int sendTagCount = 0;
|
||||||
|
for(unsigned int t=0;t<nconf.tagCount;++t) {
|
||||||
|
if ( (_localTags[t].id != nconf.tags[t].id()) || ((now - _localTags[t].lastPushed) >= ZT_CREDENTIAL_PUSH_EVERY) || (force) ) {
|
||||||
|
_localTags[t].lastPushed = now;
|
||||||
|
_localTags[t].id = nconf.tags[t].id();
|
||||||
|
sendTags[sendTagCount++] = &(nconf.tags[t]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int tagPtr = 0;
|
unsigned int tagPtr = 0;
|
||||||
while ((tagPtr < nconf.tagCount)||(sendCom)||(sendCap)) {
|
while ((tagPtr < sendTagCount)||(sendCom)||(sendCap)) {
|
||||||
Packet outp(peerAddress,RR->identity.address(),Packet::VERB_NETWORK_CREDENTIALS);
|
Packet outp(peerAddress,RR->identity.address(),Packet::VERB_NETWORK_CREDENTIALS);
|
||||||
|
|
||||||
if (sendCom) {
|
if (sendCom) {
|
||||||
|
@ -72,11 +82,9 @@ void Membership::pushCredentials(const RuntimeEnvironment *RR,const uint64_t now
|
||||||
const unsigned int tagCountAt = outp.size();
|
const unsigned int tagCountAt = outp.size();
|
||||||
outp.addSize(2);
|
outp.addSize(2);
|
||||||
unsigned int thisPacketTagCount = 0;
|
unsigned int thisPacketTagCount = 0;
|
||||||
while ((tagPtr < nconf.tagCount)&&((outp.size() + sizeof(Tag) + 32) < ZT_PROTO_MAX_PACKET_LENGTH)) {
|
while ((tagPtr < sendTagCount)&&((outp.size() + sizeof(Tag) + 32) < ZT_PROTO_MAX_PACKET_LENGTH)) {
|
||||||
if ( (_localTags[tagPtr].id != nconf.tags[tagPtr].id()) || ((now - _localTags[tagPtr].lastPushed) >= ZT_CREDENTIAL_PUSH_EVERY) || (force) ) {
|
if ( (_localTags[tagPtr].id != nconf.tags[tagPtr].id()) || ((now - _localTags[tagPtr].lastPushed) >= ZT_CREDENTIAL_PUSH_EVERY) || (force) ) {
|
||||||
_localTags[tagPtr].lastPushed = now;
|
sendTags[tagPtr]->serialize(outp);
|
||||||
_localTags[tagPtr].id = nconf.tags[tagPtr].id();
|
|
||||||
nconf.tags[tagPtr].serialize(outp);
|
|
||||||
++thisPacketTagCount;
|
++thisPacketTagCount;
|
||||||
}
|
}
|
||||||
++tagPtr;
|
++tagPtr;
|
||||||
|
|
Loading…
Add table
Reference in a new issue