Mercurial > hg > nginx
comparison src/event/quic/ngx_event_quic_ack.c @ 9192:efcdaa66df2e
QUIC: congestion control in ngx_quic_frame_sendto().
Previously ngx_quic_frame_sendto() ignored congestion control and did not
contribute to in_flight counter.
Now congestion control window is checked unless ignore_congestion flag is set.
Also, in_flight counter is incremented and the frame is stored in ctx->sent
queue if it's ack-eliciting. This behavior is now similar to
ngx_quic_output_packet().
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Wed, 29 Nov 2023 21:41:29 +0400 |
parents | c80d111340dc |
children | ce1ff81e9b92 |
comparison
equal
deleted
inserted
replaced
9191:618132842e7c | 9192:efcdaa66df2e |
---|---|
591 | 591 |
592 ngx_quic_free_frame(c, f); | 592 ngx_quic_free_frame(c, f); |
593 break; | 593 break; |
594 | 594 |
595 case NGX_QUIC_FT_PING: | 595 case NGX_QUIC_FT_PING: |
596 case NGX_QUIC_FT_PATH_CHALLENGE: | |
596 case NGX_QUIC_FT_PATH_RESPONSE: | 597 case NGX_QUIC_FT_PATH_RESPONSE: |
597 case NGX_QUIC_FT_CONNECTION_CLOSE: | 598 case NGX_QUIC_FT_CONNECTION_CLOSE: |
598 ngx_quic_free_frame(c, f); | 599 ngx_quic_free_frame(c, f); |
599 break; | 600 break; |
600 | 601 |
822 | 823 |
823 | 824 |
824 void | 825 void |
825 ngx_quic_pto_handler(ngx_event_t *ev) | 826 ngx_quic_pto_handler(ngx_event_t *ev) |
826 { | 827 { |
827 ngx_uint_t i; | 828 ngx_uint_t i, n; |
828 ngx_msec_t now; | 829 ngx_msec_t now; |
829 ngx_queue_t *q; | 830 ngx_queue_t *q; |
830 ngx_connection_t *c; | 831 ngx_connection_t *c; |
831 ngx_quic_frame_t *f, frame; | 832 ngx_quic_frame_t *f; |
832 ngx_quic_send_ctx_t *ctx; | 833 ngx_quic_send_ctx_t *ctx; |
833 ngx_quic_connection_t *qc; | 834 ngx_quic_connection_t *qc; |
834 | 835 |
835 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ev->log, 0, "quic pto timer"); | 836 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ev->log, 0, "quic pto timer"); |
836 | 837 |
863 | 864 |
864 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, | 865 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
865 "quic pto %s pto_count:%ui", | 866 "quic pto %s pto_count:%ui", |
866 ngx_quic_level_name(ctx->level), qc->pto_count); | 867 ngx_quic_level_name(ctx->level), qc->pto_count); |
867 | 868 |
868 ngx_memzero(&frame, sizeof(ngx_quic_frame_t)); | 869 for (n = 0; n < 2; n++) { |
869 | 870 |
870 frame.level = ctx->level; | 871 f = ngx_quic_alloc_frame(c); |
871 frame.type = NGX_QUIC_FT_PING; | 872 if (f == NULL) { |
872 | 873 goto failed; |
873 if (ngx_quic_frame_sendto(c, &frame, 0, qc->path) != NGX_OK | 874 } |
874 || ngx_quic_frame_sendto(c, &frame, 0, qc->path) != NGX_OK) | 875 |
875 { | 876 f->level = ctx->level; |
876 ngx_quic_close_connection(c, NGX_ERROR); | 877 f->type = NGX_QUIC_FT_PING; |
877 return; | 878 f->ignore_congestion = 1; |
879 | |
880 if (ngx_quic_frame_sendto(c, f, 0, qc->path) == NGX_ERROR) { | |
881 goto failed; | |
882 } | |
878 } | 883 } |
879 } | 884 } |
880 | 885 |
881 qc->pto_count++; | 886 qc->pto_count++; |
882 | 887 |
883 ngx_quic_set_lost_timer(c); | 888 ngx_quic_set_lost_timer(c); |
884 | 889 |
885 ngx_quic_connstate_dbg(c); | 890 ngx_quic_connstate_dbg(c); |
891 | |
892 return; | |
893 | |
894 failed: | |
895 | |
896 ngx_quic_close_connection(c, NGX_ERROR); | |
897 return; | |
886 } | 898 } |
887 | 899 |
888 | 900 |
889 ngx_int_t | 901 ngx_int_t |
890 ngx_quic_ack_packet(ngx_connection_t *c, ngx_quic_header_t *pkt) | 902 ngx_quic_ack_packet(ngx_connection_t *c, ngx_quic_header_t *pkt) |