From 0e1fc06a6f3b5c7aaa06ba370f85337176ae8a85 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 1 Apr 2014 15:55:05 -0700 Subject: The remove paths on send fail thing in Peer.cpp was not well thought out, and there is no point in mallocing the TCP write buffer. --- node/Peer.cpp | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) (limited to 'node/Peer.cpp') diff --git a/node/Peer.cpp b/node/Peer.cpp index 6e8ecc01..28926f97 100644 --- a/node/Peer.cpp +++ b/node/Peer.cpp @@ -121,30 +121,23 @@ bool Peer::send(const RuntimeEnvironment *_r,const void *data,unsigned int len,u { Mutex::Lock _l(_lock); - for(;;) { - std::vector::iterator p(_paths.begin()); - if (p == _paths.end()) - return false; - - uint64_t bestPathLastReceived = p->lastReceived(); - std::vector::iterator bestPath = p; - while (++p != _paths.end()) { - uint64_t lr = p->lastReceived(); - if (lr > bestPathLastReceived) { - bestPathLastReceived = lr; - bestPath = p; - } + std::vector::iterator p(_paths.begin()); + if (p == _paths.end()) + return false; + + uint64_t bestPathLastReceived = p->lastReceived(); + std::vector::iterator bestPath = p; + while (++p != _paths.end()) { + uint64_t lr = p->lastReceived(); + if (lr > bestPathLastReceived) { + bestPathLastReceived = lr; + bestPath = p; } + } - if (_r->sm->send(bestPath->address(),bestPath->tcp(),bestPath->type() == Path::PATH_TYPE_TCP_OUT,data,len)) { - bestPath->sent(now); - return true; - } else { - if (bestPath->fixed()) - return false; - _paths.erase(bestPath); - // ... try again and pick a different path - } + if (_r->sm->send(bestPath->address(),bestPath->tcp(),bestPath->type() == Path::PATH_TYPE_TCP_OUT,data,len)) { + bestPath->sent(now); + return true; } return false; -- cgit v1.2.3