From f18a9b3743ea48bb0c0b918923493bd242526e4c Mon Sep 17 00:00:00 2001 From: Artem Boldariev Date: Tue, 26 Jul 2022 17:36:32 +0300 Subject: [PATCH] TLS: add isc__nmsocket_timer_running() support This commit adds isc__nmsocket_timer_running() support to the generic TLS code in order to make it more compatible with TCP. --- lib/isc/netmgr/netmgr-int.h | 3 +++ lib/isc/netmgr/netmgr.c | 9 +++++++++ lib/isc/netmgr/tlsstream.c | 14 ++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/lib/isc/netmgr/netmgr-int.h b/lib/isc/netmgr/netmgr-int.h index 4bc5fc22a3..6e8a78c688 100644 --- a/lib/isc/netmgr/netmgr-int.h +++ b/lib/isc/netmgr/netmgr-int.h @@ -1583,6 +1583,9 @@ void isc__nmhandle_tls_setwritetimeout(isc_nmhandle_t *handle, uint64_t write_timeout); +bool +isc__nmsocket_tls_timer_running(isc_nmsocket_t *sock); + void isc__nm_tls_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result, bool async); diff --git a/lib/isc/netmgr/netmgr.c b/lib/isc/netmgr/netmgr.c index d3ba6f2382..ba97f97d0b 100644 --- a/lib/isc/netmgr/netmgr.c +++ b/lib/isc/netmgr/netmgr.c @@ -1545,6 +1545,15 @@ bool isc__nmsocket_timer_running(isc_nmsocket_t *sock) { REQUIRE(VALID_NMSOCK(sock)); + switch (sock->type) { +#ifdef HAVE_LIBNGHTTP2 + case isc_nm_tlssocket: + return (isc__nmsocket_tls_timer_running(sock)); +#endif /* HAVE_LIBNGHTTP2 */ + default: + break; + } + return (uv_is_active((uv_handle_t *)&sock->read_timer)); } diff --git a/lib/isc/netmgr/tlsstream.c b/lib/isc/netmgr/tlsstream.c index e1602461ee..5aae50419b 100644 --- a/lib/isc/netmgr/tlsstream.c +++ b/lib/isc/netmgr/tlsstream.c @@ -1215,6 +1215,20 @@ isc__nmsocket_tls_reset(isc_nmsocket_t *sock) { } } +bool +isc__nmsocket_tls_timer_running(isc_nmsocket_t *sock) { + REQUIRE(VALID_NMSOCK(sock)); + REQUIRE(sock->type == isc_nm_tlssocket); + + if (sock->outerhandle != NULL) { + INSIST(VALID_NMHANDLE(sock->outerhandle)); + REQUIRE(VALID_NMSOCK(sock->outerhandle->sock)); + return (isc__nmsocket_timer_running(sock->outerhandle->sock)); + } + + return (false); +} + const char * isc__nm_tls_verify_tls_peer_result_string(const isc_nmhandle_t *handle) { isc_nmsocket_t *sock = NULL;