summaryrefslogtreecommitdiff
path: root/src/ActivePeerConnectionCommand.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2013-01-24 00:18:31 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2013-01-25 00:10:11 +0900
commit8524ac38067ba2ca2e692de39166edd6612e1d5b (patch)
treea00b86ffedd3acb869324412cf2b65c7b01a875f /src/ActivePeerConnectionCommand.cc
parentde394bbf615baf0a15b4c8b53c09b94ac274f3af (diff)
Code cleanup
Diffstat (limited to 'src/ActivePeerConnectionCommand.cc')
-rw-r--r--src/ActivePeerConnectionCommand.cc9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/ActivePeerConnectionCommand.cc b/src/ActivePeerConnectionCommand.cc
index e9bf9e32..47183e4a 100644
--- a/src/ActivePeerConnectionCommand.cc
+++ b/src/ActivePeerConnectionCommand.cc
@@ -115,9 +115,11 @@ bool ActivePeerConnectionCommand::execute() {
numConnection = numNewConnection_;
}
- for(int numAdd = numConnection;
- numAdd > 0 && peerStorage_->isPeerAvailable(); --numAdd) {
+ for(; numConnection > 0; --numConnection) {
SharedHandle<Peer> peer = peerStorage_->getUnusedPeer();
+ if(!peer) {
+ break;
+ }
connectToPeer(peer);
}
if(btRuntime_->getConnections() == 0 &&
@@ -132,9 +134,6 @@ bool ActivePeerConnectionCommand::execute() {
void ActivePeerConnectionCommand::connectToPeer(const SharedHandle<Peer>& peer)
{
- if(!peer) {
- return;
- }
peer->usedBy(e_->newCUID());
PeerInitiateConnectionCommand* command =
new PeerInitiateConnectionCommand(peer->usedBy(), requestGroup_, peer, e_,