better receiving transfer cleanup (reduces log spam)
This commit is contained in:
parent
0b2fa40cb9
commit
1efae931d1
@ -198,7 +198,30 @@ void NGCFT1::iteratePeer(float time_delta, uint32_t group_number, uint32_t peer_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: receiving tranfers?
|
//for (auto& transfer_opt : peer.recv_transfers) {
|
||||||
|
for (size_t idx = 0; idx < peer.recv_transfers.size(); idx++) {
|
||||||
|
if (!peer.recv_transfers.at(idx).has_value()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& transfer = peer.recv_transfers.at(idx).value();
|
||||||
|
|
||||||
|
// proper switch case?
|
||||||
|
if (transfer.state == Group::Peer::RecvTransfer::State::FINISHING) {
|
||||||
|
transfer.finishing_timer -= time_delta;
|
||||||
|
if (transfer.finishing_timer <= 0.f) {
|
||||||
|
dispatch(
|
||||||
|
NGCFT1_Event::recv_done,
|
||||||
|
Events::NGCFT1_recv_done{
|
||||||
|
group_number, peer_number,
|
||||||
|
uint8_t(idx)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
peer.recv_transfers.at(idx).reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const CCAI* NGCFT1::getPeerCCA(
|
const CCAI* NGCFT1::getPeerCCA(
|
||||||
@ -573,20 +596,12 @@ bool NGCFT1::onEvent(const Events::NGCEXT_ft1_data& e) {
|
|||||||
|
|
||||||
|
|
||||||
if (transfer.file_size_current == transfer.file_size) {
|
if (transfer.file_size_current == transfer.file_size) {
|
||||||
// TODO: set all data received, and clean up
|
// all data received
|
||||||
//transfer.state = Group::Peer::RecvTransfer::State::RECV;
|
transfer.state = Group::Peer::RecvTransfer::State::FINISHING;
|
||||||
dispatch(
|
|
||||||
NGCFT1_Event::recv_done,
|
|
||||||
Events::NGCFT1_recv_done{
|
|
||||||
e.group_number, e.peer_number,
|
|
||||||
e.transfer_id
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// delete transfer
|
|
||||||
// TODO: keep around for remote timeout + delay + offset, so we can be sure all acks where received
|
// TODO: keep around for remote timeout + delay + offset, so we can be sure all acks where received
|
||||||
// or implement a dedicated finished that needs to be acked
|
// or implement a dedicated finished that needs to be acked
|
||||||
peer.recv_transfers[e.transfer_id].reset();
|
transfer.finishing_timer = 0.5f; // TODO: we are receiving, we dont know delay
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -155,12 +155,15 @@ class NGCFT1 : public ToxEventI, public NGCEXTEventI, public NGCFT1EventProvider
|
|||||||
enum class State {
|
enum class State {
|
||||||
INITED, //init acked, but no data received yet (might be dropped)
|
INITED, //init acked, but no data received yet (might be dropped)
|
||||||
RECV, // receiving data
|
RECV, // receiving data
|
||||||
|
FINISHING, // got all the data, but we wait for 2*delay, since its likely there is data still arriving
|
||||||
} state;
|
} state;
|
||||||
|
|
||||||
// float time_since_last_activity ?
|
|
||||||
size_t file_size {0};
|
size_t file_size {0};
|
||||||
size_t file_size_current {0};
|
size_t file_size_current {0};
|
||||||
|
|
||||||
|
// if state FINISHING and it reaches 0, delete
|
||||||
|
float finishing_timer {0.f};
|
||||||
|
|
||||||
// sequence id based reassembly
|
// sequence id based reassembly
|
||||||
RecvSequenceBuffer rsb;
|
RecvSequenceBuffer rsb;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user