2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 22:15:20 +00:00

replace per-protocol keepalive functions with a common one

this commit removes isc__nm_tcpdns_keepalive() and
isc__nm_tlsdns_keepalive(); keepalive for these protocols and
for TCP will now be set directly from isc_nmhandle_keepalive().

protocols that have an underlying TCP socket (i.e., TLS stream
and HTTP), now have protocol-specific routines, called by
isc_nmhandle_keeaplive(), to set the keepalive value on the
underlying socket.
This commit is contained in:
Evan Hunt
2021-07-14 21:12:37 -07:00
parent 7867b8b57d
commit fc6f751fbe
6 changed files with 67 additions and 49 deletions

View File

@@ -2367,16 +2367,33 @@ isc_nmhandle_settimeout(isc_nmhandle_t *handle, uint32_t timeout) {
void
isc_nmhandle_keepalive(isc_nmhandle_t *handle, bool value) {
REQUIRE(VALID_NMHANDLE(handle));
isc_nmsocket_t *sock = NULL;
switch (handle->sock->type) {
REQUIRE(VALID_NMHANDLE(handle));
REQUIRE(VALID_NMSOCK(handle->sock));
sock = handle->sock;
switch (sock->type) {
case isc_nm_tcpsocket:
case isc_nm_tcpdnssocket:
isc__nm_tcpdns_keepalive(handle, value);
break;
case isc_nm_tlsdnssocket:
isc__nm_tlsdns_keepalive(handle, value);
atomic_store(&sock->keepalive, value);
sock->read_timeout = value ? atomic_load(&sock->mgr->keepalive)
: atomic_load(&sock->mgr->idle);
break;
#if HAVE_LIBNGHTTP2
case isc_nm_tlssocket:
isc__nmhandle_tls_keepalive(handle, value);
break;
case isc_nm_httpsocket:
isc__nmhandle_http_keepalive(handle, value);
break;
#endif /* HAVE_LIBNGHTTP2 */
default:
/*
* For any other protocol, this is a no-op.
*/
return;
}
}