mirror of
https://github.com/nginx/nginx.git
synced 2025-06-21 21:31:05 +08:00
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.
This commit is contained in:
parent
e4ca695700
commit
68c5d80ee5
@ -1460,7 +1460,7 @@ ngx_quic_close_timer_handler(ngx_event_t *ev)
|
|||||||
static ngx_int_t
|
static ngx_int_t
|
||||||
ngx_quic_close_streams(ngx_connection_t *c, ngx_quic_connection_t *qc)
|
ngx_quic_close_streams(ngx_connection_t *c, ngx_quic_connection_t *qc)
|
||||||
{
|
{
|
||||||
ngx_event_t *rev;
|
ngx_event_t *rev, *wev;
|
||||||
ngx_rbtree_t *tree;
|
ngx_rbtree_t *tree;
|
||||||
ngx_rbtree_node_t *node;
|
ngx_rbtree_node_t *node;
|
||||||
ngx_quic_stream_t *qs;
|
ngx_quic_stream_t *qs;
|
||||||
@ -1486,8 +1486,12 @@ ngx_quic_close_streams(ngx_connection_t *c, ngx_quic_connection_t *qc)
|
|||||||
qs = (ngx_quic_stream_t *) node;
|
qs = (ngx_quic_stream_t *) node;
|
||||||
|
|
||||||
rev = qs->c->read;
|
rev = qs->c->read;
|
||||||
|
rev->error = 1;
|
||||||
rev->ready = 1;
|
rev->ready = 1;
|
||||||
rev->pending_eof = 1;
|
|
||||||
|
wev = qs->c->write;
|
||||||
|
wev->error = 1;
|
||||||
|
wev->ready = 1;
|
||||||
|
|
||||||
ngx_post_event(rev, &ngx_posted_events);
|
ngx_post_event(rev, &ngx_posted_events);
|
||||||
|
|
||||||
@ -4005,6 +4009,10 @@ ngx_quic_stream_recv(ngx_connection_t *c, u_char *buf, size_t size)
|
|||||||
qc = pc->quic;
|
qc = pc->quic;
|
||||||
rev = c->read;
|
rev = c->read;
|
||||||
|
|
||||||
|
if (rev->error) {
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
|
||||||
"quic stream id 0x%xL recv: eof:%d, avail:%z",
|
"quic stream id 0x%xL recv: eof:%d, avail:%z",
|
||||||
qs->id, rev->pending_eof, b->last - b->pos);
|
qs->id, rev->pending_eof, b->last - b->pos);
|
||||||
@ -4093,6 +4101,7 @@ ngx_quic_stream_send(ngx_connection_t *c, u_char *buf, size_t size)
|
|||||||
u_char *p, *end;
|
u_char *p, *end;
|
||||||
size_t fsize, limit, n, len;
|
size_t fsize, limit, n, len;
|
||||||
uint64_t sent, unacked;
|
uint64_t sent, unacked;
|
||||||
|
ngx_event_t *wev;
|
||||||
ngx_connection_t *pc;
|
ngx_connection_t *pc;
|
||||||
ngx_quic_frame_t *frame;
|
ngx_quic_frame_t *frame;
|
||||||
ngx_quic_stream_t *qs;
|
ngx_quic_stream_t *qs;
|
||||||
@ -4101,8 +4110,9 @@ ngx_quic_stream_send(ngx_connection_t *c, u_char *buf, size_t size)
|
|||||||
qs = c->qs;
|
qs = c->qs;
|
||||||
pc = qs->parent;
|
pc = qs->parent;
|
||||||
qc = pc->quic;
|
qc = pc->quic;
|
||||||
|
wev = c->write;
|
||||||
|
|
||||||
if (qc->closing) {
|
if (wev->error) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3022,6 +3022,19 @@ ngx_http_test_reading(ngx_http_request_t *r)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (NGX_HTTP_QUIC)
|
||||||
|
|
||||||
|
if (c->qs) {
|
||||||
|
if (c->read->error) {
|
||||||
|
err = 0;
|
||||||
|
goto closed;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#if (NGX_HAVE_KQUEUE)
|
#if (NGX_HAVE_KQUEUE)
|
||||||
|
|
||||||
if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
|
if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
|
||||||
|
Loading…
Reference in New Issue
Block a user