picotls_ctx_read (tls_ctx_t * ctx, session_t * tls_session)
{
picotls_ctx_t *ptls_ctx = (picotls_ctx_t *) ctx;
- int from_tls_len = 0, to_app_len = 0, crypto_len, ret;
+ int from_tls_len = 0, to_app_len = 0, off, crypto_len, ret;
u32 deq_max, deq_now;
u32 enq_max, enq_now;
ptls_buffer_t _buf, *buf = &_buf;
if (!deq_now)
goto done_hs;
- from_tls_len +=
- svm_fifo_dequeue (tls_rx_fifo, deq_now, TLS_RX_LEN (ptls_ctx));
+ off = svm_fifo_dequeue (tls_rx_fifo, deq_now, TLS_RX_LEN (ptls_ctx));
+ from_tls_len += off;
+ ptls_ctx->rx_len += off;
if (from_tls_len <= 0)
{
tls_add_vpp_q_builtin_rx_evt (tls_session);
{
deq_now = clib_min (svm_fifo_max_read_chunk (tls_rx_fifo),
deq_max - from_tls_len);
- from_tls_len += svm_fifo_dequeue (tls_rx_fifo, deq_now,
- TLS_RX_LEN (ptls_ctx));
+ off = svm_fifo_dequeue (tls_rx_fifo, deq_now,
+ TLS_RX_LEN (ptls_ctx));
+ from_tls_len += off;
+ ptls_ctx->rx_len += off;
}
- ptls_ctx->rx_len += from_tls_len;
picotls_do_handshake (ptls_ctx, tls_session, TLS_RX_OFFSET (ptls_ctx),
from_tls_len);
if (picotls_handshake_is_over (ctx))
deq_now = clib_min (deq_max, svm_fifo_max_read_chunk (tls_rx_fifo));
- from_tls_len =
- svm_fifo_dequeue (tls_rx_fifo, deq_now, TLS_RX_LEN (ptls_ctx));
+ off = svm_fifo_dequeue (tls_rx_fifo, deq_now, TLS_RX_LEN (ptls_ctx));
+ from_tls_len = off;
+ ptls_ctx->rx_len += off;
if (from_tls_len < deq_max)
{
deq_now =
clib_min (svm_fifo_max_read_chunk (tls_rx_fifo),
deq_max - from_tls_len);
- from_tls_len +=
+ off =
svm_fifo_dequeue (tls_rx_fifo, deq_now, TLS_RX_LEN (ptls_ctx));
+ from_tls_len += off;
+ ptls_ctx->rx_len += off;
}
- ptls_ctx->rx_len += from_tls_len;
-
if (from_tls_len < deq_max)
tls_add_vpp_q_builtin_rx_evt (tls_session);
}
}
crypto_len = clib_min (enq_max, TLS_RX_LEFT_LEN (ptls_ctx));
- int off = 0;
+ off = 0;
do
{
ptls_receive (ptls_ctx->tls, buf,
TLS_RX_OFFSET (ptls_ctx), &consumed);
off += consumed;
- ptls_ctx->rx_offset += consumed;
+ ptls_ctx->rx_offset += off;
}
while (ret == 0 && off < crypto_len);
to_app_len +=
svm_fifo_enqueue (app_rx_fifo, enq_now, buf->base + to_app_len);
}
- }
+ if (ptls_ctx->rx_len != 0 && !TLS_RX_IS_LEFT (ptls_ctx))
+ {
+ ptls_ctx->rx_len = 0;
+ ptls_ctx->rx_offset = 0;
+ }
- if (ptls_ctx->rx_len != 0 && !TLS_RX_IS_LEFT (ptls_ctx))
- {
- ptls_ctx->rx_len = 0;
- ptls_ctx->rx_offset = 0;
}
final: