Mercurial > hg > nginx-quic
comparison src/event/ngx_event_quic.c @ 8166:21b7dac9de3b quic
QUIC: added connection state debug to event handlers.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Mon, 26 Oct 2020 23:17:54 +0300 |
parents | c53761445a66 |
children | 4a05f0f3dfce |
comparison
equal
deleted
inserted
replaced
8165:c53761445a66 | 8166:21b7dac9de3b |
---|---|
549 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, log, 0, "quic frame %s %s %*s", | 549 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, log, 0, "quic frame %s %s %*s", |
550 tx ? "tx" : "rx", ngx_quic_level_name(f->level), | 550 tx ? "tx" : "rx", ngx_quic_level_name(f->level), |
551 p - buf, buf); | 551 p - buf, buf); |
552 } | 552 } |
553 | 553 |
554 | |
555 static void | |
556 ngx_quic_connstate_dbg(ngx_connection_t *c) | |
557 { | |
558 u_char *p, *last; | |
559 ngx_quic_connection_t *qc; | |
560 u_char buf[NGX_MAX_ERROR_STR]; | |
561 | |
562 p = buf; | |
563 last = p + sizeof(buf); | |
564 | |
565 qc = c->quic; | |
566 | |
567 p = ngx_slprintf(p, last, "state:"); | |
568 | |
569 if (qc) { | |
570 | |
571 if (qc->error) { | |
572 p = ngx_slprintf(p, last, "%s", qc->error_app ? " app" : ""); | |
573 p = ngx_slprintf(p, last, " error:%ui", qc->error); | |
574 | |
575 if (qc->error_reason) { | |
576 p = ngx_slprintf(p, last, " \"%s\"", qc->error_reason); | |
577 } | |
578 } | |
579 | |
580 p = ngx_slprintf(p, last, "%s", qc->closing ? " closing" : ""); | |
581 p = ngx_slprintf(p, last, "%s", qc->draining ? " draining" : ""); | |
582 p = ngx_slprintf(p, last, "%s", qc->key_phase ? " kp" : ""); | |
583 p = ngx_slprintf(p, last, "%s", qc->in_retry ? " retry" : ""); | |
584 p = ngx_slprintf(p, last, "%s", qc->validated? " valid" : ""); | |
585 | |
586 } else { | |
587 p = ngx_slprintf(p, last, " early"); | |
588 } | |
589 | |
590 if (c->read->timer_set) { | |
591 p = ngx_slprintf(p, last, | |
592 qc && qc->send_timer_set ? " send:%M" : " read:%M", | |
593 c->read->timer.key - ngx_current_msec); | |
594 } | |
595 | |
596 if (qc) { | |
597 | |
598 if (qc->push.timer_set) { | |
599 p = ngx_slprintf(p, last, " push:%M", | |
600 qc->push.timer.key - ngx_current_msec); | |
601 } | |
602 | |
603 if (qc->pto.timer_set) { | |
604 p = ngx_slprintf(p, last, " pto:%M", | |
605 qc->pto.timer.key - ngx_current_msec); | |
606 } | |
607 | |
608 if (qc->close.timer_set) { | |
609 p = ngx_slprintf(p, last, " close:%M", | |
610 qc->close.timer.key - ngx_current_msec); | |
611 } | |
612 } | |
613 | |
614 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, | |
615 "quic %*s", p - buf, buf); | |
616 } | |
617 | |
554 #else | 618 #else |
555 | 619 |
556 #define ngx_quic_log_frame(log, f, tx) | 620 #define ngx_quic_log_frame(log, f, tx) |
621 #define ngx_quic_connstate_dbg(c) | |
557 | 622 |
558 #endif | 623 #endif |
559 | 624 |
560 | 625 |
561 #if BORINGSSL_API_VERSION >= 10 | 626 #if BORINGSSL_API_VERSION >= 10 |
866 ngx_add_timer(c->read, c->quic->in_retry ? NGX_QUIC_RETRY_TIMEOUT | 931 ngx_add_timer(c->read, c->quic->in_retry ? NGX_QUIC_RETRY_TIMEOUT |
867 : c->quic->tp.max_idle_timeout); | 932 : c->quic->tp.max_idle_timeout); |
868 | 933 |
869 c->read->handler = ngx_quic_input_handler; | 934 c->read->handler = ngx_quic_input_handler; |
870 | 935 |
936 ngx_quic_connstate_dbg(c); | |
871 return; | 937 return; |
872 } | 938 } |
873 | 939 |
874 | 940 |
875 static ngx_quic_connection_t * | 941 static ngx_quic_connection_t * |
1571 | 1637 |
1572 /* rc == NGX_OK */ | 1638 /* rc == NGX_OK */ |
1573 | 1639 |
1574 qc->send_timer_set = 0; | 1640 qc->send_timer_set = 0; |
1575 ngx_add_timer(rev, qc->tp.max_idle_timeout); | 1641 ngx_add_timer(rev, qc->tp.max_idle_timeout); |
1642 | |
1643 ngx_quic_connstate_dbg(c); | |
1576 } | 1644 } |
1577 | 1645 |
1578 | 1646 |
1579 static void | 1647 static void |
1580 ngx_quic_close_connection(ngx_connection_t *c, ngx_int_t rc) | 1648 ngx_quic_close_connection(ngx_connection_t *c, ngx_int_t rc) |
1850 | 1918 |
1851 rc = ngx_quic_process_packet(c, conf, &pkt); | 1919 rc = ngx_quic_process_packet(c, conf, &pkt); |
1852 | 1920 |
1853 #if (NGX_DEBUG) | 1921 #if (NGX_DEBUG) |
1854 if (pkt.parsed) { | 1922 if (pkt.parsed) { |
1855 ngx_quic_connection_t *qc; | 1923 ngx_log_debug5(NGX_LOG_DEBUG_EVENT, c->log, 0, |
1856 | 1924 "quic %s pkt done decr:%d pn:%L perr:%ui rc:%i", |
1857 qc = c->quic; | |
1858 | |
1859 ngx_log_debug8(NGX_LOG_DEBUG_EVENT, c->log, 0, | |
1860 "quic pkt done %s decr:%d pn:%L pe:%ui rc:%i" | |
1861 " closing:%d err:%ui %s", | |
1862 ngx_quic_level_name(pkt.level), pkt.decrypted, | 1925 ngx_quic_level_name(pkt.level), pkt.decrypted, |
1863 pkt.pn, pkt.error, rc, (qc && qc->closing) ? 1 : 0, | 1926 pkt.pn, pkt.error, rc); |
1864 qc ? qc->error : 0, | |
1865 (qc && qc->error_reason) ? qc->error_reason : ""); | |
1866 } else { | 1927 } else { |
1867 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, | 1928 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
1868 "quic pkt done parse failed rc:%i", rc); | 1929 "quic pkt done parse failed rc:%i", rc); |
1869 } | 1930 } |
1870 #endif | 1931 #endif |
4608 "quic pto pnum:%uL pto_count:%ui level:%d", | 4669 "quic pto pnum:%uL pto_count:%ui level:%d", |
4609 start->pnum, c->quic->pto_count, start->level); | 4670 start->pnum, c->quic->pto_count, start->level); |
4610 | 4671 |
4611 ngx_quic_resend_frames(c, ctx); | 4672 ngx_quic_resend_frames(c, ctx); |
4612 } | 4673 } |
4674 | |
4675 ngx_quic_connstate_dbg(c); | |
4613 } | 4676 } |
4614 | 4677 |
4615 | 4678 |
4616 static void | 4679 static void |
4617 ngx_quic_push_handler(ngx_event_t *ev) | 4680 ngx_quic_push_handler(ngx_event_t *ev) |
4624 | 4687 |
4625 if (ngx_quic_output(c) != NGX_OK) { | 4688 if (ngx_quic_output(c) != NGX_OK) { |
4626 ngx_quic_close_connection(c, NGX_ERROR); | 4689 ngx_quic_close_connection(c, NGX_ERROR); |
4627 return; | 4690 return; |
4628 } | 4691 } |
4692 | |
4693 ngx_quic_connstate_dbg(c); | |
4629 } | 4694 } |
4630 | 4695 |
4631 | 4696 |
4632 static | 4697 static |
4633 void ngx_quic_lost_handler(ngx_event_t *ev) | 4698 void ngx_quic_lost_handler(ngx_event_t *ev) |
4639 c = ev->data; | 4704 c = ev->data; |
4640 | 4705 |
4641 if (ngx_quic_detect_lost(c) != NGX_OK) { | 4706 if (ngx_quic_detect_lost(c) != NGX_OK) { |
4642 ngx_quic_close_connection(c, NGX_ERROR); | 4707 ngx_quic_close_connection(c, NGX_ERROR); |
4643 } | 4708 } |
4709 | |
4710 ngx_quic_connstate_dbg(c); | |
4644 } | 4711 } |
4645 | 4712 |
4646 | 4713 |
4647 static ngx_int_t | 4714 static ngx_int_t |
4648 ngx_quic_detect_lost(ngx_connection_t *c) | 4715 ngx_quic_detect_lost(ngx_connection_t *c) |