Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
radkesvat committed Jul 15, 2024
1 parent c1f03bf commit a96b136
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 28 deletions.
32 changes: 19 additions & 13 deletions tunnels/client/protobuf/protobuf_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,21 +123,27 @@ static void downStream(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/2)
{
resumeLineDownSide(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);
resumeLineDownSide(c->line);
}
// if (cstate->bytes_sent_nack >= kMaxSendBeforeAck)
// {
// cstate->bytes_sent_nack -= consumed;
// // LOGD("consumed: %d left: %d", consumed, (int) cstate->bytes_sent_nack);

// if (cstate->bytes_sent_nack < kMaxSendBeforeAck / 2)
// {
// resumeLineDownSide(c->line);
// }
// }
// else
// {
// cstate->bytes_sent_nack -= consumed;
// // LOGD("consumed: %d left: %d", consumed, (int) cstate->bytes_sent_nack);
// }

if (bufLen(full_data) > 0)
{
Expand Down Expand Up @@ -169,7 +175,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);
Expand Down
35 changes: 20 additions & 15 deletions tunnels/server/protobuf/protobuf_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -92,21 +92,26 @@ 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);

if (cstate->bytes_sent_nack < kMaxSendBeforeAck/2)
{
resumeLineUpSide(c->line);
}
}
else
cstate->bytes_sent_nack -= consumed;
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 (cstate->bytes_sent_nack >= kMaxSendBeforeAck)
// {
// cstate->bytes_sent_nack -= consumed;
// // LOGD("consumed: %d left: %d", consumed, (int) cstate->bytes_sent_nack);

// if (cstate->bytes_sent_nack < kMaxSendBeforeAck / 2)
// {
// resumeLineUpSide(c->line);
// }
// }
// else
// {
// cstate->bytes_sent_nack -= consumed;
// // LOGD("consumed: %d left: %d", consumed, (int) cstate->bytes_sent_nack);
// }

if (bufLen(full_data) > 0)
{
Expand Down Expand Up @@ -138,7 +143,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);
Expand Down

0 comments on commit a96b136

Please sign in to comment.