comparison src/event/quic/ngx_event_quic_streams.c @ 9065:2ee6f9729739 quic

QUIC: set stream error flag on reset. Now, when RESET_STREAM is sent or received, or when streams are closed, stream connection error flag is set. Previously, only stream state was changed, which resulted in setting the error flag only after calling recv()/send()/send_chain(). However, there are cases when none of these functions is called, but it's still important to know if the stream is being closed. For example, when an HTTP/3 request stream is blocked on insert count, receiving RESET_STREAM should trigger stream closure, which was not the case. The change also fixes ngx_http_upstream_check_broken_connection() and ngx_http_test_reading() with QUIC streams.
author Roman Arutyunyan <arut@nginx.com>
date Tue, 10 Jan 2023 17:42:40 +0400
parents 35e27117b593
children 03897c45798e
comparison
equal deleted inserted replaced
9064:35e27117b593 9065:2ee6f9729739
201 if (sc == NULL) { 201 if (sc == NULL) {
202 ngx_quic_close_stream(qs); 202 ngx_quic_close_stream(qs);
203 continue; 203 continue;
204 } 204 }
205 205
206 sc->read->error = 1;
207 sc->write->error = 1;
208
206 ngx_quic_set_event(sc->read); 209 ngx_quic_set_event(sc->read);
207 ngx_quic_set_event(sc->write); 210 ngx_quic_set_event(sc->write);
208 211
209 sc->close = 1; 212 sc->close = 1;
210 sc->read->handler(sc->read); 213 sc->read->handler(sc->read);
242 return NGX_OK; 245 return NGX_OK;
243 } 246 }
244 247
245 qs->send_state = NGX_QUIC_STREAM_SEND_RESET_SENT; 248 qs->send_state = NGX_QUIC_STREAM_SEND_RESET_SENT;
246 qs->send_final_size = qs->send_offset; 249 qs->send_final_size = qs->send_offset;
250
251 if (qs->connection) {
252 qs->connection->write->error = 1;
253 }
247 254
248 pc = qs->parent; 255 pc = qs->parent;
249 qc = ngx_quic_get_connection(pc); 256 qc = ngx_quic_get_connection(pc);
250 257
251 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pc->log, 0, 258 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pc->log, 0,
803 810
804 if (qs->recv_state == NGX_QUIC_STREAM_RECV_RESET_RECVD 811 if (qs->recv_state == NGX_QUIC_STREAM_RECV_RESET_RECVD
805 || qs->recv_state == NGX_QUIC_STREAM_RECV_RESET_READ) 812 || qs->recv_state == NGX_QUIC_STREAM_RECV_RESET_READ)
806 { 813 {
807 qs->recv_state = NGX_QUIC_STREAM_RECV_RESET_READ; 814 qs->recv_state = NGX_QUIC_STREAM_RECV_RESET_READ;
808 rev->error = 1;
809 return NGX_ERROR; 815 return NGX_ERROR;
810 } 816 }
811 817
812 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pc->log, 0, 818 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pc->log, 0,
813 "quic stream id:0x%xL recv buf:%uz", qs->id, size); 819 "quic stream id:0x%xL recv buf:%uz", qs->id, size);
1381 1387
1382 ngx_int_t 1388 ngx_int_t
1383 ngx_quic_handle_reset_stream_frame(ngx_connection_t *c, 1389 ngx_quic_handle_reset_stream_frame(ngx_connection_t *c,
1384 ngx_quic_header_t *pkt, ngx_quic_reset_stream_frame_t *f) 1390 ngx_quic_header_t *pkt, ngx_quic_reset_stream_frame_t *f)
1385 { 1391 {
1392 ngx_event_t *rev;
1386 ngx_quic_stream_t *qs; 1393 ngx_quic_stream_t *qs;
1387 ngx_quic_connection_t *qc; 1394 ngx_quic_connection_t *qc;
1388 1395
1389 qc = ngx_quic_get_connection(c); 1396 qc = ngx_quic_get_connection(c);
1390 1397
1437 1444
1438 if (qs->connection == NULL) { 1445 if (qs->connection == NULL) {
1439 return ngx_quic_close_stream(qs); 1446 return ngx_quic_close_stream(qs);
1440 } 1447 }
1441 1448
1442 ngx_quic_set_event(qs->connection->read); 1449 rev = qs->connection->read;
1450 rev->error = 1;
1451
1452 ngx_quic_set_event(rev);
1443 1453
1444 return NGX_OK; 1454 return NGX_OK;
1445 } 1455 }
1446 1456
1447 1457