diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-04-01 15:55:05 -0700 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-04-01 15:55:05 -0700 |
| commit | 0e1fc06a6f3b5c7aaa06ba370f85337176ae8a85 (patch) | |
| tree | a7b73495b52736d100b0dfa82b38883d118edd2c /node/Peer.cpp | |
| parent | c3b41c289d891781b75819a00ec927c14842b6cd (diff) | |
| download | infinitytier-0e1fc06a6f3b5c7aaa06ba370f85337176ae8a85.tar.gz infinitytier-0e1fc06a6f3b5c7aaa06ba370f85337176ae8a85.zip | |
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.
Diffstat (limited to 'node/Peer.cpp')
| -rw-r--r-- | node/Peer.cpp | 37 |
1 files changed, 15 insertions, 22 deletions
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<Path>::iterator p(_paths.begin()); - if (p == _paths.end()) - return false; - - uint64_t bestPathLastReceived = p->lastReceived(); - std::vector<Path>::iterator bestPath = p; - while (++p != _paths.end()) { - uint64_t lr = p->lastReceived(); - if (lr > bestPathLastReceived) { - bestPathLastReceived = lr; - bestPath = p; - } + std::vector<Path>::iterator p(_paths.begin()); + if (p == _paths.end()) + return false; + + uint64_t bestPathLastReceived = p->lastReceived(); + std::vector<Path>::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; |
