diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2015-12-27 18:39:47 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2015-12-27 18:40:08 +0900 |
| commit | b1132d6b10cd3791b9529d7031d723fd0e2d8215 (patch) | |
| tree | 9ce465b42bf09372118335c7c619bb2b41869eaf /src/PeerInitiateConnectionCommand.cc | |
| parent | 4abad2f64c9ff80144a61c5a9c2bea144852b883 (diff) | |
make clang-format using clang-format-3.6
Diffstat (limited to 'src/PeerInitiateConnectionCommand.cc')
| -rw-r--r-- | src/PeerInitiateConnectionCommand.cc | 70 |
1 files changed, 33 insertions, 37 deletions
diff --git a/src/PeerInitiateConnectionCommand.cc b/src/PeerInitiateConnectionCommand.cc index 4339d5de..af8206a4 100644 --- a/src/PeerInitiateConnectionCommand.cc +++ b/src/PeerInitiateConnectionCommand.cc @@ -53,17 +53,14 @@ namespace aria2 { -PeerInitiateConnectionCommand::PeerInitiateConnectionCommand -(cuid_t cuid, - RequestGroup* requestGroup, - const std::shared_ptr<Peer>& peer, - DownloadEngine* e, - const std::shared_ptr<BtRuntime>& btRuntime, - bool mseHandshakeEnabled) - : PeerAbstractCommand(cuid, peer, e), - requestGroup_(requestGroup), - btRuntime_(btRuntime), - mseHandshakeEnabled_(mseHandshakeEnabled) +PeerInitiateConnectionCommand::PeerInitiateConnectionCommand( + cuid_t cuid, RequestGroup* requestGroup, const std::shared_ptr<Peer>& peer, + DownloadEngine* e, const std::shared_ptr<BtRuntime>& btRuntime, + bool mseHandshakeEnabled) + : PeerAbstractCommand(cuid, peer, e), + requestGroup_(requestGroup), + btRuntime_(btRuntime), + mseHandshakeEnabled_(mseHandshakeEnabled) { btRuntime_->increaseConnections(); requestGroup_->increaseNumCommand(); @@ -75,43 +72,41 @@ PeerInitiateConnectionCommand::~PeerInitiateConnectionCommand() btRuntime_->decreaseConnections(); } -bool PeerInitiateConnectionCommand::executeInternal() { - A2_LOG_INFO(fmt(MSG_CONNECTING_TO_SERVER, - getCuid(), - getPeer()->getIPAddress().c_str(), - getPeer()->getPort())); +bool PeerInitiateConnectionCommand::executeInternal() +{ + A2_LOG_INFO(fmt(MSG_CONNECTING_TO_SERVER, getCuid(), + getPeer()->getIPAddress().c_str(), getPeer()->getPort())); createSocket(); getSocket()->establishConnection(getPeer()->getIPAddress(), getPeer()->getPort(), false); getSocket()->applyIpDscp(); - if(mseHandshakeEnabled_) { - auto c = make_unique<InitiatorMSEHandshakeCommand> - (getCuid(), requestGroup_, getPeer(), - getDownloadEngine(), btRuntime_, getSocket()); + if (mseHandshakeEnabled_) { + auto c = make_unique<InitiatorMSEHandshakeCommand>( + getCuid(), requestGroup_, getPeer(), getDownloadEngine(), btRuntime_, + getSocket()); c->setPeerStorage(peerStorage_); c->setPieceStorage(pieceStorage_); getDownloadEngine()->addCommand(std::move(c)); - } else { - getDownloadEngine()->addCommand - (make_unique<PeerInteractionCommand> - (getCuid(), requestGroup_, getPeer(), - getDownloadEngine(), - btRuntime_, pieceStorage_, peerStorage_, - getSocket(), + } + else { + getDownloadEngine()->addCommand(make_unique<PeerInteractionCommand>( + getCuid(), requestGroup_, getPeer(), getDownloadEngine(), btRuntime_, + pieceStorage_, peerStorage_, getSocket(), PeerInteractionCommand::INITIATOR_SEND_HANDSHAKE)); } return true; } // TODO this method removed when PeerBalancerCommand is implemented -bool PeerInitiateConnectionCommand::prepareForNextPeer(time_t wait) { - if(peerStorage_->isPeerAvailable() && btRuntime_->lessThanEqMinPeers()) { +bool PeerInitiateConnectionCommand::prepareForNextPeer(time_t wait) +{ + if (peerStorage_->isPeerAvailable() && btRuntime_->lessThanEqMinPeers()) { cuid_t ncuid = getDownloadEngine()->newCUID(); std::shared_ptr<Peer> peer = peerStorage_->checkoutPeer(ncuid); // sanity check - if(peer) { - auto command = make_unique<PeerInitiateConnectionCommand> - (ncuid, requestGroup_, peer, getDownloadEngine(), btRuntime_); + if (peer) { + auto command = make_unique<PeerInitiateConnectionCommand>( + ncuid, requestGroup_, peer, getDownloadEngine(), btRuntime_); command->setPeerStorage(peerStorage_); command->setPieceStorage(pieceStorage_); getDownloadEngine()->addCommand(std::move(command)); @@ -120,7 +115,8 @@ bool PeerInitiateConnectionCommand::prepareForNextPeer(time_t wait) { return true; } -void PeerInitiateConnectionCommand::onAbort() { +void PeerInitiateConnectionCommand::onAbort() +{ peerStorage_->returnPeer(getPeer()); } @@ -129,14 +125,14 @@ bool PeerInitiateConnectionCommand::exitBeforeExecute() return btRuntime_->isHalt(); } -void PeerInitiateConnectionCommand::setPeerStorage -(const std::shared_ptr<PeerStorage>& peerStorage) +void PeerInitiateConnectionCommand::setPeerStorage( + const std::shared_ptr<PeerStorage>& peerStorage) { peerStorage_ = peerStorage; } -void PeerInitiateConnectionCommand::setPieceStorage -(const std::shared_ptr<PieceStorage>& pieceStorage) +void PeerInitiateConnectionCommand::setPieceStorage( + const std::shared_ptr<PieceStorage>& pieceStorage) { pieceStorage_ = pieceStorage; } |
