Mercurial > hg > nginx
comparison src/event/quic/ngx_event_quic.c @ 8995:19251fb83187 quic
QUIC: merged ngx_quic_close_quic() and ngx_quic_close_connection().
The separate ngx_quic_close_quic() doesn't make much sense.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Tue, 01 Feb 2022 13:05:38 +0300 |
parents | e00295b76395 |
children | 430755fcdb61 |
comparison
equal
deleted
inserted
replaced
8994:e00295b76395 | 8995:19251fb83187 |
---|---|
14 ngx_quic_conf_t *conf, ngx_quic_header_t *pkt); | 14 ngx_quic_conf_t *conf, ngx_quic_header_t *pkt); |
15 static ngx_int_t ngx_quic_handle_stateless_reset(ngx_connection_t *c, | 15 static ngx_int_t ngx_quic_handle_stateless_reset(ngx_connection_t *c, |
16 ngx_quic_header_t *pkt); | 16 ngx_quic_header_t *pkt); |
17 static void ngx_quic_input_handler(ngx_event_t *rev); | 17 static void ngx_quic_input_handler(ngx_event_t *rev); |
18 | 18 |
19 static ngx_int_t ngx_quic_close_quic(ngx_connection_t *c, ngx_int_t rc); | |
20 static void ngx_quic_close_timer_handler(ngx_event_t *ev); | 19 static void ngx_quic_close_timer_handler(ngx_event_t *ev); |
21 | 20 |
22 static ngx_int_t ngx_quic_handle_datagram(ngx_connection_t *c, ngx_buf_t *b, | 21 static ngx_int_t ngx_quic_handle_datagram(ngx_connection_t *c, ngx_buf_t *b, |
23 ngx_quic_conf_t *conf); | 22 ngx_quic_conf_t *conf); |
24 static ngx_int_t ngx_quic_handle_packet(ngx_connection_t *c, | 23 static ngx_int_t ngx_quic_handle_packet(ngx_connection_t *c, |
453 | 452 |
454 | 453 |
455 void | 454 void |
456 ngx_quic_close_connection(ngx_connection_t *c, ngx_int_t rc) | 455 ngx_quic_close_connection(ngx_connection_t *c, ngx_int_t rc) |
457 { | 456 { |
457 ngx_uint_t i; | |
458 ngx_pool_t *pool; | 458 ngx_pool_t *pool; |
459 ngx_quic_send_ctx_t *ctx; | |
459 ngx_quic_connection_t *qc; | 460 ngx_quic_connection_t *qc; |
460 | 461 |
461 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, | 462 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
462 "quic ngx_quic_close_connection rc:%i", rc); | 463 "quic ngx_quic_close_connection rc:%i", rc); |
463 | 464 |
467 if (rc == NGX_ERROR) { | 468 if (rc == NGX_ERROR) { |
468 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, | 469 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
469 "quic close connection early error"); | 470 "quic close connection early error"); |
470 } | 471 } |
471 | 472 |
472 } else if (ngx_quic_close_quic(c, rc) == NGX_AGAIN) { | 473 goto quic_done; |
473 return; | 474 } |
474 } | |
475 | |
476 if (c->ssl) { | |
477 (void) ngx_ssl_shutdown(c); | |
478 } | |
479 | |
480 if (c->read->timer_set) { | |
481 ngx_del_timer(c->read); | |
482 } | |
483 | |
484 #if (NGX_STAT_STUB) | |
485 (void) ngx_atomic_fetch_add(ngx_stat_active, -1); | |
486 #endif | |
487 | |
488 c->destroyed = 1; | |
489 | |
490 pool = c->pool; | |
491 | |
492 ngx_close_connection(c); | |
493 | |
494 ngx_destroy_pool(pool); | |
495 } | |
496 | |
497 | |
498 static ngx_int_t | |
499 ngx_quic_close_quic(ngx_connection_t *c, ngx_int_t rc) | |
500 { | |
501 ngx_uint_t i; | |
502 ngx_quic_send_ctx_t *ctx; | |
503 ngx_quic_connection_t *qc; | |
504 | |
505 qc = ngx_quic_get_connection(c); | |
506 | 475 |
507 if (!qc->closing) { | 476 if (!qc->closing) { |
508 | 477 |
509 /* drop packets from retransmit queues, no ack is expected */ | 478 /* drop packets from retransmit queues, no ack is expected */ |
510 for (i = 0; i < NGX_QUIC_SEND_CTX_LAST; i++) { | 479 for (i = 0; i < NGX_QUIC_SEND_CTX_LAST; i++) { |
580 /* do not wait for timer in case of fatal error */ | 549 /* do not wait for timer in case of fatal error */ |
581 ngx_del_timer(&qc->close); | 550 ngx_del_timer(&qc->close); |
582 } | 551 } |
583 | 552 |
584 if (ngx_quic_close_streams(c, qc) == NGX_AGAIN) { | 553 if (ngx_quic_close_streams(c, qc) == NGX_AGAIN) { |
585 return NGX_AGAIN; | 554 return; |
586 } | 555 } |
587 | 556 |
588 if (qc->push.timer_set) { | 557 if (qc->push.timer_set) { |
589 ngx_del_timer(&qc->push); | 558 ngx_del_timer(&qc->push); |
590 } | 559 } |
600 if (qc->push.posted) { | 569 if (qc->push.posted) { |
601 ngx_delete_posted_event(&qc->push); | 570 ngx_delete_posted_event(&qc->push); |
602 } | 571 } |
603 | 572 |
604 if (qc->close.timer_set) { | 573 if (qc->close.timer_set) { |
605 return NGX_AGAIN; | 574 return; |
606 } | 575 } |
607 | 576 |
608 ngx_quic_close_sockets(c); | 577 ngx_quic_close_sockets(c); |
609 | 578 |
610 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, | 579 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
611 "quic part of connection is terminated"); | 580 "quic part of connection is terminated"); |
612 | 581 |
613 /* may be tested from SSL callback during SSL shutdown */ | 582 /* may be tested from SSL callback during SSL shutdown */ |
614 c->udp = NULL; | 583 c->udp = NULL; |
615 | 584 |
616 return NGX_OK; | 585 quic_done: |
586 | |
587 if (c->ssl) { | |
588 (void) ngx_ssl_shutdown(c); | |
589 } | |
590 | |
591 if (c->read->timer_set) { | |
592 ngx_del_timer(c->read); | |
593 } | |
594 | |
595 #if (NGX_STAT_STUB) | |
596 (void) ngx_atomic_fetch_add(ngx_stat_active, -1); | |
597 #endif | |
598 | |
599 c->destroyed = 1; | |
600 | |
601 pool = c->pool; | |
602 | |
603 ngx_close_connection(c); | |
604 | |
605 ngx_destroy_pool(pool); | |
617 } | 606 } |
618 | 607 |
619 | 608 |
620 void | 609 void |
621 ngx_quic_finalize_connection(ngx_connection_t *c, ngx_uint_t err, | 610 ngx_quic_finalize_connection(ngx_connection_t *c, ngx_uint_t err, |