comparison src/event/ngx_event_quic.c @ 8503:b66a2a041d7e quic

QUIC: fixed ngx_http_test_reading() for QUIC streams. Previously this function generated an error trying to figure out if client shut down the write end of the connection. The reason for this error was that a QUIC stream has no socket descriptor. However checking for eof is not the right thing to do for an HTTP/3 QUIC stream since HTTP/3 clients are expected to shut down the write end of the stream after sending the request. Now the function handles QUIC streams separately. It checks if c->read->error is set. The error flags for c->read and c->write are now set for all streams when closing the QUIC connection instead of setting the pending_eof flag.
author Roman Arutyunyan <arut@nginx.com>
date Tue, 11 Aug 2020 10:41:39 +0300
parents 69033a50c3ae
children d277e25e37fc
comparison
equal deleted inserted replaced
8502:69033a50c3ae 8503:b66a2a041d7e
1458 1458
1459 1459
1460 static ngx_int_t 1460 static ngx_int_t
1461 ngx_quic_close_streams(ngx_connection_t *c, ngx_quic_connection_t *qc) 1461 ngx_quic_close_streams(ngx_connection_t *c, ngx_quic_connection_t *qc)
1462 { 1462 {
1463 ngx_event_t *rev; 1463 ngx_event_t *rev, *wev;
1464 ngx_rbtree_t *tree; 1464 ngx_rbtree_t *tree;
1465 ngx_rbtree_node_t *node; 1465 ngx_rbtree_node_t *node;
1466 ngx_quic_stream_t *qs; 1466 ngx_quic_stream_t *qs;
1467 1467
1468 #if (NGX_DEBUG) 1468 #if (NGX_DEBUG)
1484 node = ngx_rbtree_next(tree, node)) 1484 node = ngx_rbtree_next(tree, node))
1485 { 1485 {
1486 qs = (ngx_quic_stream_t *) node; 1486 qs = (ngx_quic_stream_t *) node;
1487 1487
1488 rev = qs->c->read; 1488 rev = qs->c->read;
1489 rev->error = 1;
1489 rev->ready = 1; 1490 rev->ready = 1;
1490 rev->pending_eof = 1; 1491
1492 wev = qs->c->write;
1493 wev->error = 1;
1494 wev->ready = 1;
1491 1495
1492 ngx_post_event(rev, &ngx_posted_events); 1496 ngx_post_event(rev, &ngx_posted_events);
1493 1497
1494 if (rev->timer_set) { 1498 if (rev->timer_set) {
1495 ngx_del_timer(rev); 1499 ngx_del_timer(rev);
4003 b = qs->b; 4007 b = qs->b;
4004 pc = qs->parent; 4008 pc = qs->parent;
4005 qc = pc->quic; 4009 qc = pc->quic;
4006 rev = c->read; 4010 rev = c->read;
4007 4011
4012 if (rev->error) {
4013 return NGX_ERROR;
4014 }
4015
4008 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, 4016 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
4009 "quic stream id 0x%xL recv: eof:%d, avail:%z", 4017 "quic stream id 0x%xL recv: eof:%d, avail:%z",
4010 qs->id, rev->pending_eof, b->last - b->pos); 4018 qs->id, rev->pending_eof, b->last - b->pos);
4011 4019
4012 if (b->pos == b->last) { 4020 if (b->pos == b->last) {
4091 ngx_quic_stream_send(ngx_connection_t *c, u_char *buf, size_t size) 4099 ngx_quic_stream_send(ngx_connection_t *c, u_char *buf, size_t size)
4092 { 4100 {
4093 u_char *p, *end; 4101 u_char *p, *end;
4094 size_t fsize, limit, n, len; 4102 size_t fsize, limit, n, len;
4095 uint64_t sent, unacked; 4103 uint64_t sent, unacked;
4104 ngx_event_t *wev;
4096 ngx_connection_t *pc; 4105 ngx_connection_t *pc;
4097 ngx_quic_frame_t *frame; 4106 ngx_quic_frame_t *frame;
4098 ngx_quic_stream_t *qs; 4107 ngx_quic_stream_t *qs;
4099 ngx_quic_connection_t *qc; 4108 ngx_quic_connection_t *qc;
4100 4109
4101 qs = c->qs; 4110 qs = c->qs;
4102 pc = qs->parent; 4111 pc = qs->parent;
4103 qc = pc->quic; 4112 qc = pc->quic;
4104 4113 wev = c->write;
4105 if (qc->closing) { 4114
4115 if (wev->error) {
4106 return NGX_ERROR; 4116 return NGX_ERROR;
4107 } 4117 }
4108 4118
4109 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, 4119 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
4110 "quic stream id 0x%xL send: %uz", qs->id, size); 4120 "quic stream id 0x%xL send: %uz", qs->id, size);