limit pending requests
This commit is contained in:
parent
099abc3a09
commit
845586c2db
@ -427,8 +427,10 @@ void SHA1_NGCFT1::iterate(float delta) {
|
|||||||
} else if (!_queue_content_want_chunk.empty()) {
|
} else if (!_queue_content_want_chunk.empty()) {
|
||||||
const auto ce = _queue_content_want_chunk.front();
|
const auto ce = _queue_content_want_chunk.front();
|
||||||
|
|
||||||
// select chunk/make sure we still need one
|
auto& requested_chunks = ce.get_or_emplace<Components::FT1ChunkSHA1Requested>().chunks;
|
||||||
|
if (requested_chunks.size() < _max_pending_requests) {
|
||||||
|
|
||||||
|
// select chunk/make sure we still need one
|
||||||
auto selected_peer_opt = selectPeerForRequest(ce);
|
auto selected_peer_opt = selectPeerForRequest(ce);
|
||||||
if (selected_peer_opt.has_value()) {
|
if (selected_peer_opt.has_value()) {
|
||||||
const auto [group_number, peer_number] = selected_peer_opt.value();
|
const auto [group_number, peer_number] = selected_peer_opt.value();
|
||||||
@ -455,7 +457,6 @@ void SHA1_NGCFT1::iterate(float delta) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& requested_chunks = ce.get_or_emplace<Components::FT1ChunkSHA1Requested>().chunks;
|
|
||||||
if (requested_chunks.count(chunk_idx)) {
|
if (requested_chunks.count(chunk_idx)) {
|
||||||
// already requested
|
// already requested
|
||||||
continue;
|
continue;
|
||||||
@ -483,6 +484,7 @@ void SHA1_NGCFT1::iterate(float delta) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SHA1_NGCFT1::onEvent(const Message::Events::MessageUpdated& e) {
|
bool SHA1_NGCFT1::onEvent(const Message::Events::MessageUpdated& e) {
|
||||||
@ -878,6 +880,12 @@ bool SHA1_NGCFT1::onEvent(const Events::NGCFT1_recv_done& e) {
|
|||||||
if (info.chunks.at(chunk_index) == got_hash) {
|
if (info.chunks.at(chunk_index) == got_hash) {
|
||||||
std::cout << "SHA1_NGCFT1: got chunk [" << SHA1Digest{got_hash} << "]\n";
|
std::cout << "SHA1_NGCFT1: got chunk [" << SHA1Digest{got_hash} << "]\n";
|
||||||
|
|
||||||
|
// remove from requested
|
||||||
|
// TODO: remove at init and track running transfers differently
|
||||||
|
for (const auto it : std::get<ReceivingTransfer::Chunk>(tv).chunk_indices) {
|
||||||
|
ce.get_or_emplace<Components::FT1ChunkSHA1Requested>().chunks.erase(it);
|
||||||
|
}
|
||||||
|
|
||||||
if (!cc.have_all) {
|
if (!cc.have_all) {
|
||||||
for (const auto inner_chunk_index : std::get<ReceivingTransfer::Chunk>(tv).chunk_indices) {
|
for (const auto inner_chunk_index : std::get<ReceivingTransfer::Chunk>(tv).chunk_indices) {
|
||||||
if (!cc.have_all && !cc.have_chunk.at(inner_chunk_index)) {
|
if (!cc.have_all && !cc.have_chunk.at(inner_chunk_index)) {
|
||||||
|
@ -104,6 +104,8 @@ class SHA1_NGCFT1 : public RegistryMessageModelEventI, public NGCFT1EventI {
|
|||||||
|
|
||||||
size_t _max_concurrent_in {4};
|
size_t _max_concurrent_in {4};
|
||||||
size_t _max_concurrent_out {6};
|
size_t _max_concurrent_out {6};
|
||||||
|
// TODO: probably also includes running transfers rn (meh)
|
||||||
|
size_t _max_pending_requests {16}; // per content
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SHA1_NGCFT1(
|
SHA1_NGCFT1(
|
||||||
|
Loading…
Reference in New Issue
Block a user