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 // delete, timed out 3 times
fprintf(stderr, "FT: warning, ft init timed out, deleting\n"); fprintf(stderr, "FT: warning, ft init timed out, deleting\n");
tf_opt.reset(); tf_opt.reset();
continue; continue; // dangerous control flow
} else { } else {
// timed out, resend // timed out, resend
fprintf(stderr, "FT: warning, ft init timed out, resending\n"); 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; break;
case State::SENDING: { case State::SENDING: {
tf.ssb.for_each(0.025f, [&](uint16_t id, const std::vector<uint8_t>& data, float& time_since_activity) { 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 // no ack after 5 sec -> resend
if (time_since_activity >= 10.f) { if (time_since_activity >= 5.f) {
_send_pkg_FT1_DATA(tox, group_number, peer_number, idx, id, data.data(), data.size()); _send_pkg_FT1_DATA(tox, group_number, peer_number, idx, id, data.data(), data.size());
time_since_activity = 0.f; 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)); assert(ngc_ft1_ctx->cb_send_data.count(tf.file_kind));
// if chunks in flight < window size (1 lol) // if chunks in flight < window size (1 lol)