diff options
| author | Roman Arutyunyan <arut@nginx.com> | 2022-02-14 15:27:59 +0300 |
|---|---|---|
| committer | Roman Arutyunyan <arut@nginx.com> | 2022-02-14 15:27:59 +0300 |
| commit | 8b3a050f3b5995631f1a8011916283b9b7424d6b (patch) | |
| tree | e90ed757434e4cb3c1d8310d0ef00861474ac718 /src/event/quic/ngx_event_quic_ssl.c | |
| parent | 7c4b4f4d540de7959311ab0f6bfafac5ab46f67b (diff) | |
| download | nginx-8b3a050f3b5995631f1a8011916283b9b7424d6b.tar.gz nginx-8b3a050f3b5995631f1a8011916283b9b7424d6b.tar.bz2 | |
QUIC: ngx_quic_buffer_t object.
The object is used instead of ngx_chain_t pointer for buffer operations like
ngx_quic_write_chain() and ngx_quic_read_chain(). These functions are renamed
to ngx_quic_write_buffer() and ngx_quic_read_buffer().
Diffstat (limited to 'src/event/quic/ngx_event_quic_ssl.c')
| -rw-r--r-- | src/event/quic/ngx_event_quic_ssl.c | 50 |
1 files changed, 13 insertions, 37 deletions
diff --git a/src/event/quic/ngx_event_quic_ssl.c b/src/event/quic/ngx_event_quic_ssl.c index 126758253..8e01a8742 100644 --- a/src/event/quic/ngx_event_quic_ssl.c +++ b/src/event/quic/ngx_event_quic_ssl.c @@ -331,10 +331,8 @@ ngx_int_t ngx_quic_handle_crypto_frame(ngx_connection_t *c, ngx_quic_header_t *pkt, ngx_quic_frame_t *frame) { - size_t len; uint64_t last; - ngx_buf_t *b; - ngx_chain_t *cl, **ll; + ngx_chain_t *cl; ngx_quic_send_ctx_t *ctx; ngx_quic_connection_t *qc; ngx_quic_crypto_frame_t *f; @@ -346,12 +344,12 @@ ngx_quic_handle_crypto_frame(ngx_connection_t *c, ngx_quic_header_t *pkt, /* no overflow since both values are 62-bit */ last = f->offset + f->length; - if (last > ctx->crypto_received + NGX_QUIC_MAX_BUFFERED) { + if (last > ctx->crypto.offset + NGX_QUIC_MAX_BUFFERED) { qc->error = NGX_QUIC_ERR_CRYPTO_BUFFER_EXCEEDED; return NGX_ERROR; } - if (last <= ctx->crypto_received) { + if (last <= ctx->crypto.offset) { if (pkt->level == ssl_encryption_initial) { /* speeding up handshake completion */ @@ -368,45 +366,23 @@ ngx_quic_handle_crypto_frame(ngx_connection_t *c, ngx_quic_header_t *pkt, return NGX_OK; } - if (f->offset > ctx->crypto_received) { - if (ngx_quic_write_chain(c, &ctx->crypto, frame->data, f->length, - f->offset - ctx->crypto_received, NULL) - == NGX_CHAIN_ERROR) - { + if (f->offset == ctx->crypto.offset) { + if (ngx_quic_crypto_input(c, frame->data) != NGX_OK) { return NGX_ERROR; } - return NGX_OK; - } - - ngx_quic_trim_chain(frame->data, ctx->crypto_received - f->offset); - - if (ngx_quic_crypto_input(c, frame->data) != NGX_OK) { - return NGX_ERROR; - } + ngx_quic_skip_buffer(c, &ctx->crypto, last); - ngx_quic_trim_chain(ctx->crypto, last - ctx->crypto_received); - ctx->crypto_received = last; - - cl = ctx->crypto; - ll = &cl; - len = 0; - - while (*ll) { - b = (*ll)->buf; - - if (b->sync && b->pos != b->last) { - /* hole */ - break; + } else { + if (ngx_quic_write_buffer(c, &ctx->crypto, frame->data, f->length, + f->offset) + == NGX_CHAIN_ERROR) + { + return NGX_ERROR; } - - len += b->last - b->pos; - ll = &(*ll)->next; } - ctx->crypto_received += len; - ctx->crypto = *ll; - *ll = NULL; + cl = ngx_quic_read_buffer(c, &ctx->crypto, (uint64_t) -1); if (cl) { if (ngx_quic_crypto_input(c, cl) != NGX_OK) { |
