diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-11-25 15:49:20 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-11-25 15:49:20 +0000 |
| commit | 46d9f2de6373007895e84f577aa8ae413cd4e861 (patch) | |
| tree | 5ab170329d937cb4fea2f04c76675062b832d0f5 /src/PeerReceiveHandshakeCommand.cc | |
| parent | a26a44cb8ed28d59930bfaa4553fbd1fa7fbcb4d (diff) | |
2009-11-26 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed the bug which causes segmentation fault with tellWaiting
XML-RPC method when BitTorrent download is waiting. The key of
BtRegistry is changed from info hash to GID, because it is
registered per RequestGroup, not info hash.
* src/BtRegistry.cc
* src/BtRegistry.h
* src/BtSetup.cc
* src/ConsoleStatCalc.cc
* src/InitiatorMSEHandshakeCommand.cc
* src/PeerInitiateConnectionCommand.cc
* src/PeerInteractionCommand.cc
* src/PeerInteractionCommand.h
* src/PeerReceiveHandshakeCommand.cc
* src/RequestGroup.cc
* src/XmlRpcMethodImpl.cc
* test/BtRegistryTest.cc
* test/XmlRpcMethodTest.cc
Diffstat (limited to 'src/PeerReceiveHandshakeCommand.cc')
| -rw-r--r-- | src/PeerReceiveHandshakeCommand.cc | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/PeerReceiveHandshakeCommand.cc b/src/PeerReceiveHandshakeCommand.cc index 8052dda5..337cd5ec 100644 --- a/src/PeerReceiveHandshakeCommand.cc +++ b/src/PeerReceiveHandshakeCommand.cc @@ -93,17 +93,24 @@ bool PeerReceiveHandshakeCommand::executeInternal() // check info_hash std::string infoHash = std::string(&data[28], &data[28+INFO_HASH_LENGTH]); - BtObject btObject = e->getBtRegistry()->get(infoHash); - SharedHandle<DownloadContext> downloadContext = btObject._downloadContext; + SharedHandle<DownloadContext> downloadContext = + e->getBtRegistry()->getDownloadContext(infoHash); + if(downloadContext.isNull()) { + throw DL_ABORT_EX + (StringFormat("Unknown info hash %s", + util::toHex(infoHash).c_str()).str()); + } + BtObject btObject = e->getBtRegistry()->get + (downloadContext->getOwnerRequestGroup()->getGID()); SharedHandle<BtRuntime> btRuntime = btObject._btRuntime; SharedHandle<PieceStorage> pieceStorage = btObject._pieceStorage; SharedHandle<PeerStorage> peerStorage = btObject._peerStorage; - - if(downloadContext.isNull() || !btRuntime->ready()) { + if(!btRuntime->ready()) { throw DL_ABORT_EX (StringFormat("Unknown info hash %s", util::toHex(infoHash).c_str()).str()); } + TransferStat tstat = downloadContext->getOwnerRequestGroup()->calculateStat(); const unsigned int maxDownloadLimit = @@ -130,10 +137,10 @@ bool PeerReceiveHandshakeCommand::executeInternal() e, btRuntime, pieceStorage, + peerStorage, socket, PeerInteractionCommand::RECEIVER_WAIT_HANDSHAKE, _peerConnection); - command->setPeerStorage(peerStorage); e->commands.push_back(command); logger->debug(MSG_INCOMING_PEER_CONNECTION, cuid, peer->usedBy()); } |
