Compare commits

...

3 Commits

Author SHA1 Message Date
5bb4349e27
missing include 2023-01-16 17:08:09 +01:00
a449739050
tweaking and less log spam 2023-01-16 15:45:04 +01:00
bbe4453833
reduce init retry/timeout cooldown 2023-01-16 12:37:46 +01:00

View File

@ -10,6 +10,7 @@
#include <map> #include <map>
#include <optional> #include <optional>
#include <cassert> #include <cassert>
#include <cstdio>
struct SendSequenceBuffer { struct SendSequenceBuffer {
struct SSBEntry { struct SSBEntry {
@ -224,7 +225,7 @@ void NGC_FT1_iterate(Tox *tox, NGC_FT1* ngc_ft1_ctx) {
switch (tf.state) { switch (tf.state) {
using State = NGC_FT1::Group::Peer::SendTransfer::State; using State = NGC_FT1::Group::Peer::SendTransfer::State;
case State::INIT_SENT: case State::INIT_SENT:
if (tf.time_since_activity >= 20.f) { if (tf.time_since_activity >= 10.f) {
if (tf.inits_sent >= 3) { if (tf.inits_sent >= 3) {
// 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");
@ -258,11 +259,12 @@ void NGC_FT1_iterate(Tox *tox, NGC_FT1* ngc_ft1_ctx) {
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 (2)
while (tf.ssb.size() < 1) { static const size_t window_size {2}; // TODO: expose
while (tf.ssb.size() < window_size) {
std::vector<uint8_t> new_data; std::vector<uint8_t> new_data;
size_t chunk_size = std::min<size_t>(400u, tf.file_size - tf.file_size_current); size_t chunk_size = std::min<size_t>(450u, tf.file_size - tf.file_size_current);
if (chunk_size == 0) { if (chunk_size == 0) {
// TODO: set to finishing? // TODO: set to finishing?
break; // we done break; // we done
@ -281,7 +283,9 @@ void NGC_FT1_iterate(Tox *tox, NGC_FT1* ngc_ft1_ctx) {
uint16_t seq_id = tf.ssb.add(std::move(new_data)); uint16_t seq_id = tf.ssb.add(std::move(new_data));
_send_pkg_FT1_DATA(tox, group_number, peer_number, idx, seq_id, tf.ssb.entries.at(seq_id).data.data(), tf.ssb.entries.at(seq_id).data.size()); _send_pkg_FT1_DATA(tox, group_number, peer_number, idx, seq_id, tf.ssb.entries.at(seq_id).data.data(), tf.ssb.entries.at(seq_id).data.size());
#if defined(EXTRA_LOGGING) && EXTRA_LOGGING == 1
fprintf(stderr, "FT: sent data size: %ld (seq %d)\n", chunk_size, seq_id); fprintf(stderr, "FT: sent data size: %ld (seq %d)\n", chunk_size, seq_id);
#endif
tf.file_size_current += chunk_size; tf.file_size_current += chunk_size;
} }
@ -623,7 +627,9 @@ static void _handle_FT1_INIT(
if (accept_ft) { if (accept_ft) {
_send_pkg_FT1_INIT_ACK(tox, group_number, peer_number, transfer_id); _send_pkg_FT1_INIT_ACK(tox, group_number, peer_number, transfer_id);
#if defined(EXTRA_LOGGING) && EXTRA_LOGGING == 1
fprintf(stderr, "FT: accepted init\n"); fprintf(stderr, "FT: accepted init\n");
#endif
auto& peer = ngc_ft1_ctx->groups[group_number].peers[peer_number]; auto& peer = ngc_ft1_ctx->groups[group_number].peers[peer_number];
if (peer.recv_transfers[transfer_id].has_value()) { if (peer.recv_transfers[transfer_id].has_value()) {
fprintf(stderr, "FT: overwriting existing recv_transfer %d\n", transfer_id); fprintf(stderr, "FT: overwriting existing recv_transfer %d\n", transfer_id);