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:
@@ -3064,6 +3064,23 @@ isc__nm_http_settimeout(isc_nmhandle_t *handle, uint32_t timeout) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
isc__nmhandle_http_keepalive(isc_nmhandle_t *handle, bool value) {
|
||||||
|
isc_nmsocket_t *sock = NULL;
|
||||||
|
|
||||||
|
REQUIRE(VALID_NMHANDLE(handle));
|
||||||
|
REQUIRE(VALID_NMSOCK(handle->sock));
|
||||||
|
REQUIRE(handle->sock->type == isc_nm_httpsocket);
|
||||||
|
|
||||||
|
sock = handle->sock;
|
||||||
|
if (sock->h2.session != NULL && sock->h2.session->handle) {
|
||||||
|
INSIST(VALID_HTTP2_SESSION(sock->h2.session));
|
||||||
|
INSIST(VALID_NMHANDLE(sock->h2.session->handle));
|
||||||
|
|
||||||
|
isc_nmhandle_keepalive(sock->h2.session->handle, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DoH GET Query String Scanner-less Recursive Descent Parser/Verifier
|
* DoH GET Query String Scanner-less Recursive Descent Parser/Verifier
|
||||||
*
|
*
|
||||||
|
@@ -1517,15 +1517,6 @@ isc__nm_tcpdns_cancelread(isc_nmhandle_t *handle);
|
|||||||
* Stop reading on a connected TCPDNS handle.
|
* Stop reading on a connected TCPDNS handle.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
|
||||||
isc__nm_tcpdns_keepalive(isc_nmhandle_t *handle, bool value);
|
|
||||||
/*%<
|
|
||||||
* Enable/disable keepalive on this connection by setting it to 'value'.
|
|
||||||
*
|
|
||||||
* When keepalive is active, we switch to using the keepalive timeout
|
|
||||||
* to determine when to close a connection, rather than the idle timeout.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void
|
void
|
||||||
isc__nm_tlsdns_send(isc_nmhandle_t *handle, isc_region_t *region,
|
isc__nm_tlsdns_send(isc_nmhandle_t *handle, isc_region_t *region,
|
||||||
isc_nm_cb_t cb, void *cbarg);
|
isc_nm_cb_t cb, void *cbarg);
|
||||||
@@ -1564,15 +1555,6 @@ isc__nm_tlsdns_cancelread(isc_nmhandle_t *handle);
|
|||||||
* Stop reading on a connected TLSDNS handle.
|
* Stop reading on a connected TLSDNS handle.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
|
||||||
isc__nm_tlsdns_keepalive(isc_nmhandle_t *handle, bool value);
|
|
||||||
/*%<
|
|
||||||
* Enable/disable keepalive on this connection by setting it to 'value'.
|
|
||||||
*
|
|
||||||
* When keepalive is active, we switch to using the keepalive timeout
|
|
||||||
* to determine when to close a connection, rather than the idle timeout.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void
|
void
|
||||||
isc__nm_async_tlsdnscycle(isc__networker_t *worker, isc__netievent_t *ev0);
|
isc__nm_async_tlsdnscycle(isc__networker_t *worker, isc__netievent_t *ev0);
|
||||||
void
|
void
|
||||||
@@ -1647,6 +1629,12 @@ isc__nm_tls_cleartimeout(isc_nmhandle_t *handle);
|
|||||||
* around.
|
* around.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
isc__nmhandle_tls_keepalive(isc_nmhandle_t *handle, bool value);
|
||||||
|
/*%<
|
||||||
|
* Set the keepalive value on the underlying TCP handle.
|
||||||
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
isc__nm_http_stoplistening(isc_nmsocket_t *sock);
|
isc__nm_http_stoplistening(isc_nmsocket_t *sock);
|
||||||
|
|
||||||
@@ -1660,6 +1648,12 @@ isc__nm_http_cleartimeout(isc_nmhandle_t *handle);
|
|||||||
* around.
|
* around.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
isc__nmhandle_http_keepalive(isc_nmhandle_t *handle, bool value);
|
||||||
|
/*%<
|
||||||
|
* Set the keepalive value on the underlying session handle
|
||||||
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
isc__nm_http_initsocket(isc_nmsocket_t *sock);
|
isc__nm_http_initsocket(isc_nmsocket_t *sock);
|
||||||
|
|
||||||
|
@@ -2367,16 +2367,33 @@ isc_nmhandle_settimeout(isc_nmhandle_t *handle, uint32_t timeout) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
isc_nmhandle_keepalive(isc_nmhandle_t *handle, bool value) {
|
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:
|
case isc_nm_tcpdnssocket:
|
||||||
isc__nm_tcpdns_keepalive(handle, value);
|
|
||||||
break;
|
|
||||||
case isc_nm_tlsdnssocket:
|
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;
|
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:
|
default:
|
||||||
|
/*
|
||||||
|
* For any other protocol, this is a no-op.
|
||||||
|
*/
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1435,16 +1435,3 @@ isc__nm_async_tcpdnscancel(isc__networker_t *worker, isc__netievent_t *ev0) {
|
|||||||
|
|
||||||
isc__nm_failed_read_cb(sock, ISC_R_EOF, false);
|
isc__nm_failed_read_cb(sock, ISC_R_EOF, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
isc__nm_tcpdns_keepalive(isc_nmhandle_t *handle, bool value) {
|
|
||||||
isc_nmsocket_t *sock = NULL;
|
|
||||||
|
|
||||||
REQUIRE(VALID_NMHANDLE(handle));
|
|
||||||
REQUIRE(VALID_NMSOCK(handle->sock));
|
|
||||||
REQUIRE(handle->sock->type == isc_nm_tcpdnssocket);
|
|
||||||
|
|
||||||
sock = handle->sock;
|
|
||||||
|
|
||||||
atomic_store(&sock->keepalive, value);
|
|
||||||
}
|
|
||||||
|
@@ -2005,16 +2005,3 @@ isc__nm_async_tlsdnscancel(isc__networker_t *worker, isc__netievent_t *ev0) {
|
|||||||
|
|
||||||
isc__nm_failed_read_cb(sock, ISC_R_EOF, false);
|
isc__nm_failed_read_cb(sock, ISC_R_EOF, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
isc__nm_tlsdns_keepalive(isc_nmhandle_t *handle, bool value) {
|
|
||||||
isc_nmsocket_t *sock = NULL;
|
|
||||||
|
|
||||||
REQUIRE(VALID_NMHANDLE(handle));
|
|
||||||
REQUIRE(VALID_NMSOCK(handle->sock));
|
|
||||||
REQUIRE(handle->sock->type == isc_nm_tlsdnssocket);
|
|
||||||
|
|
||||||
sock = handle->sock;
|
|
||||||
|
|
||||||
atomic_store(&sock->keepalive, value);
|
|
||||||
}
|
|
||||||
|
@@ -1043,3 +1043,19 @@ isc__nm_tls_settimeout(isc_nmhandle_t *handle, uint32_t timeout) {
|
|||||||
isc_nmhandle_settimeout(sock->outerhandle, timeout);
|
isc_nmhandle_settimeout(sock->outerhandle, timeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
isc__nmhandle_tls_keepalive(isc_nmhandle_t *handle, bool value) {
|
||||||
|
isc_nmsocket_t *sock = NULL;
|
||||||
|
|
||||||
|
REQUIRE(VALID_NMHANDLE(handle));
|
||||||
|
REQUIRE(VALID_NMSOCK(handle->sock));
|
||||||
|
REQUIRE(handle->sock->type == isc_nm_tlssocket);
|
||||||
|
|
||||||
|
sock = handle->sock;
|
||||||
|
if (sock->outerhandle != NULL) {
|
||||||
|
INSIST(VALID_NMHANDLE(sock->outerhandle));
|
||||||
|
|
||||||
|
isc_nmhandle_keepalive(sock->outerhandle, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user