timeout started filetransfers

This commit is contained in:
Green Sky 2023-01-13 16:23:28 +01:00
parent 1f4c2a39c5
commit 9e262120b0
No known key found for this signature in database

View File

@ -249,7 +249,7 @@ void NGC_FT1_iterate(Tox *tox, NGC_FT1* ngc_ft1_ctx) {
// delete, timed out 3 times
fprintf(stderr, "FT: warning, ft init timed out, deleting\n");
tf_opt.reset();
continue;
continue; // dangerous control flow
} else {
// timed out, resend
fprintf(stderr, "FT: warning, ft init timed out, resending\n");
@ -261,13 +261,21 @@ void NGC_FT1_iterate(Tox *tox, NGC_FT1* ngc_ft1_ctx) {
break;
case State::SENDING: {
tf.ssb.for_each(0.025f, [&](uint16_t id, const std::vector<uint8_t>& data, float& time_since_activity) {
// no ack after 10 sec -> resend
if (time_since_activity >= 10.f) {
// no ack after 5 sec -> resend
if (time_since_activity >= 5.f) {
_send_pkg_FT1_DATA(tox, group_number, peer_number, idx, id, data.data(), data.size());
time_since_activity = 0.f;
}
});
if (tf.time_since_activity >= 30.f) {
// no ack after 30sec, close ft
// TODO: notify app
fprintf(stderr, "FT: warning, sending ft in progress timed out, deleting\n");
tf_opt.reset();
continue; // dangerous control flow
}
assert(ngc_ft1_ctx->cb_send_data.count(tf.file_kind));
// if chunks in flight < window size (1 lol)