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);
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;
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) {
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));
}
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");
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);
+ }
}