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

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
return DRing::DataTransferError::invalid_argument;
}
void
DataTransferFacade::close(const DRing::DataTransferId &id) noexcept
{
pimpl_->map_.erase(id);
}
DRing::DataTransferError
DataTransferFacade::bytesProgress(const DRing::DataTransferId& id,
int64_t& total, int64_t& progress) const noexcept
......
......@@ -54,7 +54,10 @@ public:
int64_t offset) noexcept;
/// \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
DRing::DataTransferError info(const DRing::DataTransferId& id,
......
......@@ -884,6 +884,7 @@ DhtPeerConnector::Impl::eventLoop()
element.second->hasStreamWithId(id));
});
if (it == servers_.end()) {
Manager::instance().dataTransfers->close(id);
break;
}
auto peer = it->first.second; // tmp copy to prevent use-after-free below
......@@ -899,6 +900,7 @@ DhtPeerConnector::Impl::eventLoop()
connectedPeers_.erase(peer);
// Else it's via TURN!
turnEndpoints_.erase(peer);
Manager::instance().dataTransfers->close(id);
}
break;
......
Markdown is supported
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