From dda7f737f7455d75855aee2675662c790734be27 Mon Sep 17 00:00:00 2001 From: Radkesvat <134321679+radkesvat@users.noreply.github.com> Date: Mon, 15 Jul 2024 04:29:53 +0000 Subject: [PATCH] update constants --- tunnels/client/protobuf/protobuf_client.c | 18 ++++-------------- tunnels/server/protobuf/protobuf_server.c | 19 +++++-------------- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/tunnels/client/protobuf/protobuf_client.c b/tunnels/client/protobuf/protobuf_client.c index 479b485..4a47ad3 100644 --- a/tunnels/client/protobuf/protobuf_client.c +++ b/tunnels/client/protobuf/protobuf_client.c @@ -122,21 +122,11 @@ static void downStream(tunnel_t *self, context_t *c) memcpy(&consumed, rawBuf(full_data), sizeof(uint32_t)); consumed = ntohl(consumed); shiftr(full_data, sizeof(uint32_t)); + cstate->bytes_sent_nack -= consumed; - if (cstate->bytes_sent_nack >= kMaxSendBeforeAck) + if (cstate->bytes_sent_nack < kMaxSendBeforeAck / 2) { - cstate->bytes_sent_nack -= consumed; - // LOGD("consumed: %d left: %d", consumed, (int) cstate->bytes_sent_nack); - - if (cstate->bytes_sent_nack < kMaxSendBeforeAck) - { - resumeLineDownSide(c->line); - } - } - else - { - cstate->bytes_sent_nack -= consumed; - // LOGD("consumed: %d left: %d", consumed, (int) cstate->bytes_sent_nack); + resumeLineDownSide(c->line); } if (bufLen(full_data) > 0) @@ -169,7 +159,7 @@ static void downStream(tunnel_t *self, context_t *c) context_t *send_flow_ctx = newContextFrom(c); send_flow_ctx->payload = flowctl_buf; self->up->upStream(self->up, send_flow_ctx); - + if (! isAlive(c->line)) { reuseBuffer(getContextBufferPool(c), full_data); diff --git a/tunnels/server/protobuf/protobuf_server.c b/tunnels/server/protobuf/protobuf_server.c index 3428671..0869552 100644 --- a/tunnels/server/protobuf/protobuf_server.c +++ b/tunnels/server/protobuf/protobuf_server.c @@ -66,7 +66,7 @@ static void upStream(tunnel_t *self, context_t *c) const uint8_t *uleb_data = rawBuf(full_data); uint64_t data_len = 0; size_t bytes_passed = readUleb128ToUint64(uleb_data, uleb_data + bufLen(full_data), &data_len); - + if (data_len == 0 || (bufLen(full_data) - (bytes_passed)) < data_len) { shiftl(full_data, 1); // bring the data back to its original form @@ -92,20 +92,11 @@ static void upStream(tunnel_t *self, context_t *c) consumed = ntohl(consumed); shiftr(full_data, sizeof(uint32_t)); - if (cstate->bytes_sent_nack >= kMaxSendBeforeAck) - { - cstate->bytes_sent_nack -= consumed; - // LOGD("consumed: %d left: %d", consumed, (int) cstate->bytes_sent_nack); + cstate->bytes_sent_nack -= consumed; - if (cstate->bytes_sent_nack < kMaxSendBeforeAck) - { - resumeLineUpSide(c->line); - } - } - else + if (cstate->bytes_sent_nack < kMaxSendBeforeAck / 2) { - cstate->bytes_sent_nack -= consumed; - // LOGD("consumed: %d left: %d", consumed, (int) cstate->bytes_sent_nack); + resumeLineUpSide(c->line); } if (bufLen(full_data) > 0) @@ -138,7 +129,7 @@ static void upStream(tunnel_t *self, context_t *c) context_t *send_flow_ctx = newContextFrom(c); send_flow_ctx->payload = flowctl_buf; self->dw->downStream(self->dw, send_flow_ctx); - if (! isAlive(c->line)) + if (! isAlive(c->line)) { reuseBuffer(getContextBufferPool(c), full_data); destroyContext(c);