diff --git a/tunnels/client/protobuf/protobuf_client.c b/tunnels/client/protobuf/protobuf_client.c index 14b0dd2..e5a27f8 100644 --- a/tunnels/client/protobuf/protobuf_client.c +++ b/tunnels/client/protobuf/protobuf_client.c @@ -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) { @@ -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); diff --git a/tunnels/server/protobuf/protobuf_server.c b/tunnels/server/protobuf/protobuf_server.c index 1af722b..f76e72f 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,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) { @@ -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);