2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

TCP: add manual read timer control mode

This commit adds a manual read timer control mode to the TCP
code (adding isc__nmhandle_set_manual_timer() as the interface to it).

Manual read timer control mode suppresses read timer restarting the
read timer when receiving any amount of data. This way the read timer
can be controlled manually using:

* isc__nmsocket_timer_start();
* isc__nmsocket_timer_stop();
* isc__nmsocket_timer_restart().

The change is required to make it possible to implement more
sophisticated read timer control policies in DNS transports, built on
top of TCP.
This commit is contained in:
Artem Boldariev
2022-10-18 15:21:10 +03:00
parent f4760358f8
commit 9aabd55725
3 changed files with 49 additions and 2 deletions

View File

@@ -762,7 +762,9 @@ isc__nm_tcp_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb, void *cbarg) {
goto failure;
}
isc__nmsocket_timer_start(sock);
if (!sock->manual_read_timer) {
isc__nmsocket_timer_start(sock);
}
return;
failure:
@@ -831,7 +833,7 @@ isc__nm_tcp_read_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) {
isc__nm_readcb(sock, req, ISC_R_SUCCESS, false);
/* The readcb could have paused the reading */
if (sock->reading) {
if (sock->reading && !sock->manual_read_timer) {
/* The timer will be updated */
isc__nmsocket_timer_restart(sock);
}
@@ -1225,3 +1227,18 @@ isc__nm_tcp_shutdown(isc_nmsocket_t *sock) {
isc__nmsocket_prep_destroy(sock);
}
}
void
isc__nmhandle_tcp_set_manual_timer(isc_nmhandle_t *handle, const bool manual) {
isc_nmsocket_t *sock;
REQUIRE(VALID_NMHANDLE(handle));
sock = handle->sock;
REQUIRE(VALID_NMSOCK(sock));
REQUIRE(sock->type == isc_nm_tcpsocket);
REQUIRE(sock->tid == isc_tid());
REQUIRE(!sock->reading);
REQUIRE(!sock->recv_read);
sock->manual_read_timer = manual;
}