Commit d1d064d8 authored by Sébastien Blin's avatar Sébastien Blin
Browse files

data_transfer: clear map when id is not used anymore

Change-Id: I635ec67b90fc1ae90556a208f451750ceebbfeaa
parent ecf198bf
...@@ -740,6 +740,12 @@ DataTransferFacade::cancel(const DRing::DataTransferId& id) noexcept ...@@ -740,6 +740,12 @@ DataTransferFacade::cancel(const DRing::DataTransferId& id) noexcept
return DRing::DataTransferError::invalid_argument; return DRing::DataTransferError::invalid_argument;
} }
void
DataTransferFacade::close(const DRing::DataTransferId &id) noexcept
{
pimpl_->map_.erase(id);
}
DRing::DataTransferError DRing::DataTransferError
DataTransferFacade::bytesProgress(const DRing::DataTransferId& id, DataTransferFacade::bytesProgress(const DRing::DataTransferId& id,
int64_t& total, int64_t& progress) const noexcept int64_t& total, int64_t& progress) const noexcept
......
...@@ -54,7 +54,10 @@ public: ...@@ -54,7 +54,10 @@ public:
int64_t offset) noexcept; int64_t offset) noexcept;
/// \see DRing::cancelDataTransfer /// \see DRing::cancelDataTransfer
DRing::DataTransferError cancel(const DRing::DataTransferId& id) noexcept; DRing::DataTransferError cancel(const DRing::DataTransferId &id) noexcept;
/// Used by p2p.cpp
void close(const DRing::DataTransferId &id) noexcept;
/// \see DRing::dataTransferInfo /// \see DRing::dataTransferInfo
DRing::DataTransferError info(const DRing::DataTransferId& id, DRing::DataTransferError info(const DRing::DataTransferId& id,
......
...@@ -884,6 +884,7 @@ DhtPeerConnector::Impl::eventLoop() ...@@ -884,6 +884,7 @@ DhtPeerConnector::Impl::eventLoop()
element.second->hasStreamWithId(id)); element.second->hasStreamWithId(id));
}); });
if (it == servers_.end()) { if (it == servers_.end()) {
Manager::instance().dataTransfers->close(id);
break; break;
} }
auto peer = it->first.second; // tmp copy to prevent use-after-free below auto peer = it->first.second; // tmp copy to prevent use-after-free below
...@@ -899,6 +900,7 @@ DhtPeerConnector::Impl::eventLoop() ...@@ -899,6 +900,7 @@ DhtPeerConnector::Impl::eventLoop()
connectedPeers_.erase(peer); connectedPeers_.erase(peer);
// Else it's via TURN! // Else it's via TURN!
turnEndpoints_.erase(peer); turnEndpoints_.erase(peer);
Manager::instance().dataTransfers->close(id);
} }
break; break;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment