comparison src/event/ngx_event_quic.c @ 8556:b383120afca3 quic

QUIC: resend frames by moving them to output queue. Previously, when a packet was declared lost, another packet was sent with the same frames. Now lost frames are moved to the output frame queue and push event is posted. This has the advantage of forming packets with more frames than before. Also, the start argument is removed from the ngx_quic_resend_frames() function as excess information.
author Roman Arutyunyan <arut@nginx.com>
date Wed, 30 Sep 2020 20:23:16 +0100
parents dbcb9d0a3df1
children 2727d402e5a5
comparison
equal deleted inserted replaced
8555:8b6486f0fe79 8556:b383120afca3
287 static void ngx_quic_set_packet_number(ngx_quic_header_t *pkt, 287 static void ngx_quic_set_packet_number(ngx_quic_header_t *pkt,
288 ngx_quic_send_ctx_t *ctx); 288 ngx_quic_send_ctx_t *ctx);
289 static void ngx_quic_pto_handler(ngx_event_t *ev); 289 static void ngx_quic_pto_handler(ngx_event_t *ev);
290 static void ngx_quic_lost_handler(ngx_event_t *ev); 290 static void ngx_quic_lost_handler(ngx_event_t *ev);
291 static ngx_int_t ngx_quic_detect_lost(ngx_connection_t *c); 291 static ngx_int_t ngx_quic_detect_lost(ngx_connection_t *c);
292 static ngx_int_t ngx_quic_resend_frames(ngx_connection_t *c, 292 static void ngx_quic_resend_frames(ngx_connection_t *c,
293 ngx_quic_send_ctx_t *ctx, ngx_quic_frame_t *start); 293 ngx_quic_send_ctx_t *ctx);
294 static void ngx_quic_push_handler(ngx_event_t *ev); 294 static void ngx_quic_push_handler(ngx_event_t *ev);
295 295
296 static void ngx_quic_rbtree_insert_stream(ngx_rbtree_node_t *temp, 296 static void ngx_quic_rbtree_insert_stream(ngx_rbtree_node_t *temp,
297 ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel); 297 ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel);
298 static ngx_quic_stream_t *ngx_quic_find_stream(ngx_rbtree_t *rbtree, 298 static ngx_quic_stream_t *ngx_quic_find_stream(ngx_rbtree_t *rbtree,
4116 4116
4117 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, 4117 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
4118 "quic pto pnum:%uL pto_count:%ui level:%d", 4118 "quic pto pnum:%uL pto_count:%ui level:%d",
4119 start->pnum, c->quic->pto_count, start->level); 4119 start->pnum, c->quic->pto_count, start->level);
4120 4120
4121 if (ngx_quic_resend_frames(c, ctx, start) != NGX_OK) { 4121 ngx_quic_resend_frames(c, ctx);
4122 ngx_quic_close_connection(c, NGX_ERROR);
4123 return;
4124 }
4125 } 4122 }
4126 } 4123 }
4127 4124
4128 4125
4129 static void 4126 static void
4207 } 4204 }
4208 4205
4209 break; 4206 break;
4210 } 4207 }
4211 4208
4212 if (ngx_quic_resend_frames(c, ctx, start) != NGX_OK) { 4209 ngx_quic_resend_frames(c, ctx);
4213 return NGX_ERROR;
4214 }
4215 } 4210 }
4216 } 4211 }
4217 4212
4218 /* no more preceeding packets */ 4213 /* no more preceeding packets */
4219 4214
4232 4227
4233 return NGX_OK; 4228 return NGX_OK;
4234 } 4229 }
4235 4230
4236 4231
4237 static ngx_int_t 4232 static void
4238 ngx_quic_resend_frames(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx, 4233 ngx_quic_resend_frames(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx)
4239 ngx_quic_frame_t *start) 4234 {
4240 { 4235 ngx_queue_t *q;
4241 ngx_queue_t *q, range; 4236 ngx_quic_frame_t *f, *start;
4242 ngx_quic_frame_t *f; 4237 ngx_quic_connection_t *qc;
4243 4238
4244 ngx_queue_init(&range); 4239 qc = c->quic;
4245
4246 /* send frames with same packet number to the wire */
4247
4248 q = ngx_queue_head(&ctx->sent); 4240 q = ngx_queue_head(&ctx->sent);
4241 start = ngx_queue_data(q, ngx_quic_frame_t, queue);
4242
4243 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
4244 "quic resend packet pnum:%uL", start->pnum);
4249 4245
4250 do { 4246 do {
4251 f = ngx_queue_data(q, ngx_quic_frame_t, queue); 4247 f = ngx_queue_data(q, ngx_quic_frame_t, queue);
4252 4248
4253 if (f->pnum != start->pnum) { 4249 if (f->pnum != start->pnum) {
4255 } 4251 }
4256 4252
4257 q = ngx_queue_next(q); 4253 q = ngx_queue_next(q);
4258 4254
4259 ngx_queue_remove(&f->queue); 4255 ngx_queue_remove(&f->queue);
4260 ngx_queue_insert_tail(&range, &f->queue); 4256 ngx_queue_insert_tail(&ctx->frames, &f->queue);
4261 4257
4262 } while (q != ngx_queue_sentinel(&ctx->sent)); 4258 } while (q != ngx_queue_sentinel(&ctx->sent));
4263 4259
4264 ngx_quic_congestion_lost(c, start); 4260 ngx_quic_congestion_lost(c, start);
4265 4261
4266 return ngx_quic_send_frames(c, ctx, &range); 4262 if (qc->closing) {
4263 return;
4264 }
4265
4266 ngx_post_event(&qc->push, &ngx_posted_events);
4267 } 4267 }
4268 4268
4269 4269
4270 ngx_connection_t * 4270 ngx_connection_t *
4271 ngx_quic_open_stream(ngx_connection_t *c, ngx_uint_t bidi) 4271 ngx_quic_open_stream(ngx_connection_t *c, ngx_uint_t bidi)