@@ -3441,12 +3441,22 @@ static ngtcp2_ssize conn_write_pkt(ngtcp2_conn *conn, ngtcp2_pkt_info *pi,
3441
3441
}
3442
3442
3443
3443
switch ((* pfrc )-> fr .type ) {
3444
+ case NGTCP2_FRAME_RESET_STREAM :
3445
+ strm =
3446
+ ngtcp2_conn_find_stream (conn , (* pfrc )-> fr .reset_stream .stream_id );
3447
+ if (strm == NULL ||
3448
+ !ngtcp2_strm_require_retransmit_reset_stream (strm )) {
3449
+ frc = * pfrc ;
3450
+ * pfrc = (* pfrc )-> next ;
3451
+ ngtcp2_frame_chain_objalloc_del (frc , & conn -> frc_objalloc , conn -> mem );
3452
+ continue ;
3453
+ }
3454
+ break ;
3444
3455
case NGTCP2_FRAME_STOP_SENDING :
3445
3456
strm =
3446
3457
ngtcp2_conn_find_stream (conn , (* pfrc )-> fr .stop_sending .stream_id );
3447
3458
if (strm == NULL ||
3448
- ((strm -> flags & NGTCP2_STRM_FLAG_SHUT_RD ) &&
3449
- ngtcp2_strm_rx_offset (strm ) == strm -> rx .last_offset )) {
3459
+ !ngtcp2_strm_require_retransmit_stop_sending (strm )) {
3450
3460
frc = * pfrc ;
3451
3461
* pfrc = (* pfrc )-> next ;
3452
3462
ngtcp2_frame_chain_objalloc_del (frc , & conn -> frc_objalloc , conn -> mem );
@@ -3476,10 +3486,8 @@ static ngtcp2_ssize conn_write_pkt(ngtcp2_conn *conn, ngtcp2_pkt_info *pi,
3476
3486
case NGTCP2_FRAME_MAX_STREAM_DATA :
3477
3487
strm = ngtcp2_conn_find_stream (conn ,
3478
3488
(* pfrc )-> fr .max_stream_data .stream_id );
3479
- if (strm == NULL ||
3480
- (strm -> flags &
3481
- (NGTCP2_STRM_FLAG_SHUT_RD | NGTCP2_STRM_FLAG_STOP_SENDING )) ||
3482
- (* pfrc )-> fr .max_stream_data .max_stream_data < strm -> rx .max_offset ) {
3489
+ if (strm == NULL || !ngtcp2_strm_require_retransmit_max_stream_data (
3490
+ strm , & (* pfrc )-> fr .max_stream_data )) {
3483
3491
frc = * pfrc ;
3484
3492
* pfrc = (* pfrc )-> next ;
3485
3493
ngtcp2_frame_chain_objalloc_del (frc , & conn -> frc_objalloc , conn -> mem );
@@ -3497,8 +3505,8 @@ static ngtcp2_ssize conn_write_pkt(ngtcp2_conn *conn, ngtcp2_pkt_info *pi,
3497
3505
case NGTCP2_FRAME_STREAM_DATA_BLOCKED :
3498
3506
strm = ngtcp2_conn_find_stream (
3499
3507
conn , (* pfrc )-> fr .stream_data_blocked .stream_id );
3500
- if (strm == NULL || ( strm -> flags & NGTCP2_STRM_FLAG_SHUT_WR ) ||
3501
- (* pfrc )-> fr .stream_data_blocked . offset != strm -> tx . max_offset ) {
3508
+ if (strm == NULL || ! ngtcp2_strm_require_retransmit_stream_data_blocked (
3509
+ strm , & (* pfrc )-> fr .stream_data_blocked ) ) {
3502
3510
frc = * pfrc ;
3503
3511
* pfrc = (* pfrc )-> next ;
3504
3512
ngtcp2_frame_chain_objalloc_del (frc , & conn -> frc_objalloc , conn -> mem );
@@ -7145,7 +7153,7 @@ static int conn_recv_stream(ngtcp2_conn *conn, const ngtcp2_stream *fr) {
7145
7153
return rv ;
7146
7154
}
7147
7155
}
7148
- } else if (fr -> datacnt ) {
7156
+ } else if (fr -> datacnt && !( strm -> flags & NGTCP2_STRM_FLAG_STOP_SENDING ) ) {
7149
7157
rv = ngtcp2_strm_recv_reordering (strm , fr -> data [0 ].base , fr -> data [0 ].len ,
7150
7158
fr -> offset );
7151
7159
if (rv != 0 ) {
@@ -7304,27 +7312,20 @@ static int conn_recv_reset_stream(ngtcp2_conn *conn,
7304
7312
}
7305
7313
7306
7314
/* Stream is reset before we create ngtcp2_strm object. */
7307
- conn -> rx . offset += fr -> final_size ;
7308
- ngtcp2_conn_extend_max_offset ( conn , fr -> final_size );
7309
-
7310
- rv = conn_call_stream_reset ( conn , fr -> stream_id , fr -> final_size ,
7311
- fr -> app_error_code , NULL );
7315
+ strm = ngtcp2_objalloc_strm_get ( & conn -> strm_objalloc ) ;
7316
+ if ( strm == NULL ) {
7317
+ return NGTCP2_ERR_NOMEM ;
7318
+ }
7319
+ rv = ngtcp2_conn_init_stream ( conn , strm , fr -> stream_id , NULL );
7312
7320
if (rv != 0 ) {
7321
+ ngtcp2_objalloc_strm_release (& conn -> strm_objalloc , strm );
7313
7322
return rv ;
7314
7323
}
7315
7324
7316
- /* There will be no activity in this stream because we got
7317
- RESET_STREAM and don't write stream data any further. This
7318
- effectively allows another new stream for peer. */
7319
- if (bidi ) {
7320
- handle_max_remote_streams_extension (& conn -> remote .bidi .unsent_max_streams ,
7321
- 1 );
7322
- } else {
7323
- handle_max_remote_streams_extension (& conn -> remote .uni .unsent_max_streams ,
7324
- 1 );
7325
+ rv = conn_call_stream_open (conn , strm );
7326
+ if (rv != 0 ) {
7327
+ return rv ;
7325
7328
}
7326
-
7327
- return 0 ;
7328
7329
}
7329
7330
7330
7331
if ((strm -> flags & NGTCP2_STRM_FLAG_SHUT_RD )) {
@@ -7461,15 +7462,16 @@ static int conn_recv_stop_sending(ngtcp2_conn *conn,
7461
7462
been acknowledged. */
7462
7463
if (!ngtcp2_strm_is_all_tx_data_fin_acked (strm ) &&
7463
7464
!(strm -> flags & NGTCP2_STRM_FLAG_RESET_STREAM )) {
7465
+ strm -> flags |= NGTCP2_STRM_FLAG_RESET_STREAM ;
7466
+
7464
7467
rv = conn_reset_stream (conn , strm , fr -> app_error_code );
7465
7468
if (rv != 0 ) {
7466
7469
return rv ;
7467
7470
}
7468
7471
}
7469
7472
7470
- strm -> flags |= NGTCP2_STRM_FLAG_SHUT_WR |
7471
- NGTCP2_STRM_FLAG_STOP_SENDING_RECVED |
7472
- NGTCP2_STRM_FLAG_RESET_STREAM ;
7473
+ strm -> flags |=
7474
+ NGTCP2_STRM_FLAG_SHUT_WR | NGTCP2_STRM_FLAG_STOP_SENDING_RECVED ;
7473
7475
7474
7476
ngtcp2_strm_streamfrq_clear (strm );
7475
7477
@@ -12533,14 +12535,15 @@ static int conn_shutdown_stream_read(ngtcp2_conn *conn, ngtcp2_strm *strm,
12533
12535
12534
12536
/* Extend connection flow control window for the amount of data
12535
12537
which are not passed to application. */
12536
- if (!(strm -> flags & (NGTCP2_STRM_FLAG_STOP_SENDING |
12537
- NGTCP2_STRM_FLAG_RESET_STREAM_RECVED ))) {
12538
+ if (!(strm -> flags & NGTCP2_STRM_FLAG_RESET_STREAM_RECVED )) {
12538
12539
ngtcp2_conn_extend_max_offset (conn , strm -> rx .last_offset -
12539
12540
ngtcp2_strm_rx_offset (strm ));
12540
12541
}
12541
12542
12542
12543
strm -> flags |= NGTCP2_STRM_FLAG_STOP_SENDING ;
12543
12544
12545
+ ngtcp2_strm_discard_reordered_data (strm );
12546
+
12544
12547
return conn_stop_sending (conn , strm , app_error_code );
12545
12548
}
12546
12549
0 commit comments