From 9e262120b0d04055f9b3efa59fcbfca2da2a2baf Mon Sep 17 00:00:00 2001 From: Green Sky Date: Fri, 13 Jan 2023 16:23:28 +0100 Subject: [PATCH] timeout started filetransfers --- ngc_ft1.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ngc_ft1.cpp b/ngc_ft1.cpp index 679d57c..19e78c2 100644 --- a/ngc_ft1.cpp +++ b/ngc_ft1.cpp @@ -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& 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)