mirror of
https://github.com/nginx/nginx.git
synced 2024-11-27 15:39:01 +08:00
QUIC: post close event for connection close.
Previously, close event was used only for close timeout, while read event was used for posting connection close.
This commit is contained in:
parent
62b928a45f
commit
a89167c247
@ -15,8 +15,7 @@ static ngx_quic_connection_t *ngx_quic_new_connection(ngx_connection_t *c,
|
||||
static ngx_int_t ngx_quic_handle_stateless_reset(ngx_connection_t *c,
|
||||
ngx_quic_header_t *pkt);
|
||||
static void ngx_quic_input_handler(ngx_event_t *rev);
|
||||
|
||||
static void ngx_quic_close_timer_handler(ngx_event_t *ev);
|
||||
static void ngx_quic_close_handler(ngx_event_t *ev);
|
||||
|
||||
static ngx_int_t ngx_quic_handle_datagram(ngx_connection_t *c, ngx_buf_t *b,
|
||||
ngx_quic_conf_t *conf);
|
||||
@ -283,6 +282,11 @@ ngx_quic_new_connection(ngx_connection_t *c, ngx_quic_conf_t *conf,
|
||||
qc->push.handler = ngx_quic_push_handler;
|
||||
qc->push.cancelable = 1;
|
||||
|
||||
qc->close.log = c->log;
|
||||
qc->close.data = c;
|
||||
qc->close.handler = ngx_quic_close_handler;
|
||||
qc->close.cancelable = 1;
|
||||
|
||||
qc->path_validation.log = c->log;
|
||||
qc->path_validation.data = c;
|
||||
qc->path_validation.handler = ngx_quic_path_validation_handler;
|
||||
@ -420,19 +424,11 @@ ngx_quic_input_handler(ngx_event_t *rev)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!rev->ready) {
|
||||
if (qc->closing) {
|
||||
ngx_quic_close_connection(c, NGX_OK);
|
||||
|
||||
} else if (qc->shutdown) {
|
||||
ngx_quic_shutdown_quic(c);
|
||||
}
|
||||
|
||||
b = c->udp->buffer;
|
||||
if (b == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
b = c->udp->buffer;
|
||||
|
||||
rc = ngx_quic_handle_datagram(c, b, NULL);
|
||||
|
||||
if (rc == NGX_ERROR) {
|
||||
@ -520,11 +516,6 @@ ngx_quic_close_connection(ngx_connection_t *c, ngx_int_t rc)
|
||||
qc->error_reason ? qc->error_reason : "");
|
||||
|
||||
if (rc == NGX_OK) {
|
||||
qc->close.log = c->log;
|
||||
qc->close.data = c;
|
||||
qc->close.handler = ngx_quic_close_timer_handler;
|
||||
qc->close.cancelable = 1;
|
||||
|
||||
ctx = ngx_quic_get_send_ctx(qc, qc->error_level);
|
||||
ngx_add_timer(&qc->close, 3 * ngx_quic_pto(c, ctx));
|
||||
}
|
||||
@ -570,6 +561,10 @@ ngx_quic_close_connection(ngx_connection_t *c, ngx_int_t rc)
|
||||
return;
|
||||
}
|
||||
|
||||
if (qc->close.posted) {
|
||||
ngx_delete_posted_event(&qc->close);
|
||||
}
|
||||
|
||||
ngx_quic_close_sockets(c);
|
||||
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, "quic close completed");
|
||||
@ -633,14 +628,22 @@ ngx_quic_shutdown_connection(ngx_connection_t *c, ngx_uint_t err,
|
||||
|
||||
|
||||
static void
|
||||
ngx_quic_close_timer_handler(ngx_event_t *ev)
|
||||
ngx_quic_close_handler(ngx_event_t *ev)
|
||||
{
|
||||
ngx_connection_t *c;
|
||||
ngx_connection_t *c;
|
||||
ngx_quic_connection_t *qc;
|
||||
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ev->log, 0, "quic close timer");
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ev->log, 0, "quic close handler");
|
||||
|
||||
c = ev->data;
|
||||
ngx_quic_close_connection(c, NGX_DONE);
|
||||
qc = ngx_quic_get_connection(c);
|
||||
|
||||
if (qc->closing) {
|
||||
ngx_quic_close_connection(c, NGX_OK);
|
||||
|
||||
} else if (qc->shutdown) {
|
||||
ngx_quic_shutdown_quic(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1031,7 +1031,7 @@ ngx_quic_close_stream(ngx_quic_stream_t *qs)
|
||||
|
||||
if (qc->closing) {
|
||||
/* schedule handler call to continue ngx_quic_close_connection() */
|
||||
ngx_post_event(pc->read, &ngx_posted_events);
|
||||
ngx_post_event(&qc->close, &ngx_posted_events);
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
@ -1057,7 +1057,7 @@ ngx_quic_close_stream(ngx_quic_stream_t *qs)
|
||||
}
|
||||
|
||||
if (qc->shutdown) {
|
||||
ngx_post_event(pc->read, &ngx_posted_events);
|
||||
ngx_post_event(&qc->close, &ngx_posted_events);
|
||||
}
|
||||
|
||||
return NGX_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user