2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-03 16:15:27 +00:00

use handles for isc_nm_pauseread() and isc_nm_resumeread()

by having these functions act on netmgr handles instead of socket
objects, they can be used in callback functions outside the netgmr.
This commit is contained in:
Evan Hunt
2020-07-01 16:17:09 -07:00
parent 29dcdeba1b
commit 55896df79d
4 changed files with 24 additions and 15 deletions

View File

@@ -204,9 +204,12 @@ isc_result_t
isc_nm_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb, void *cbarg); isc_nm_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb, void *cbarg);
isc_result_t isc_result_t
isc_nm_pauseread(isc_nmsocket_t *sock); isc_nm_pauseread(isc_nmhandle_t *handle);
/*%< /*%<
* Pause reading on this socket, while still remembering the callback. * Pause reading on this handle's socket, but remember the callback.
*
* Requires:
* \li 'handle' is a valid netmgr handle.
*/ */
void void
@@ -221,13 +224,13 @@ isc_nm_cancelread(isc_nmhandle_t *handle);
*/ */
isc_result_t isc_result_t
isc_nm_resumeread(isc_nmsocket_t *sock); isc_nm_resumeread(isc_nmhandle_t *handle);
/*%< /*%<
* Resume reading from socket. * Resume reading on the handle's socket.
* *
* Requires: * Requires:
* \li 'sock' is a valid netmgr socket * \li 'handle' is a valid netmgr handle.
* \li ...for which a read/recv callback has been defined. * \li ...for a socket with a defined read/recv callback.
*/ */
isc_result_t isc_result_t

View File

@@ -1379,8 +1379,10 @@ isc_nm_cancelread(isc_nmhandle_t *handle) {
} }
isc_result_t isc_result_t
isc_nm_pauseread(isc_nmsocket_t *sock) { isc_nm_pauseread(isc_nmhandle_t *handle) {
REQUIRE(VALID_NMSOCK(sock)); REQUIRE(VALID_NMHANDLE(handle));
isc_nmsocket_t *sock = handle->sock;
switch (sock->type) { switch (sock->type) {
case isc_nm_tcpsocket: case isc_nm_tcpsocket:
@@ -1392,8 +1394,10 @@ isc_nm_pauseread(isc_nmsocket_t *sock) {
} }
isc_result_t isc_result_t
isc_nm_resumeread(isc_nmsocket_t *sock) { isc_nm_resumeread(isc_nmhandle_t *handle) {
REQUIRE(VALID_NMSOCK(sock)); REQUIRE(VALID_NMHANDLE(handle));
isc_nmsocket_t *sock = handle->sock;
switch (sock->type) { switch (sock->type) {
case isc_nm_tcpsocket: case isc_nm_tcpsocket:

View File

@@ -283,7 +283,7 @@ dnslisten_readcb(isc_nmhandle_t *handle, isc_result_t eresult,
* one packet, so we're done until the next read * one packet, so we're done until the next read
* completes. * completes.
*/ */
isc_nm_pauseread(dnssock->outerhandle->sock); isc_nm_pauseread(dnssock->outerhandle);
done = true; done = true;
} else { } else {
/* /*
@@ -295,7 +295,7 @@ dnslisten_readcb(isc_nmhandle_t *handle, isc_result_t eresult,
*/ */
if (atomic_load(&dnssock->ah) >= if (atomic_load(&dnssock->ah) >=
TCPDNS_CLIENTS_PER_CONN) { TCPDNS_CLIENTS_PER_CONN) {
isc_nm_pauseread(dnssock->outerhandle->sock); isc_nm_pauseread(dnssock->outerhandle);
done = true; done = true;
} }
} }
@@ -376,7 +376,7 @@ isc_nm_tcpdns_sequential(isc_nmhandle_t *handle) {
* closehandle_cb callback, called whenever a handle * closehandle_cb callback, called whenever a handle
* is released. * is released.
*/ */
isc_nm_pauseread(handle->sock->outerhandle->sock); isc_nm_pauseread(handle->sock->outerhandle);
atomic_store(&handle->sock->sequential, true); atomic_store(&handle->sock->sequential, true);
} }
@@ -431,7 +431,7 @@ resume_processing(void *arg) {
} }
isc_nmhandle_unref(handle); isc_nmhandle_unref(handle);
} else if (sock->outerhandle != NULL) { } else if (sock->outerhandle != NULL) {
result = isc_nm_resumeread(sock->outerhandle->sock); result = isc_nm_resumeread(sock->outerhandle);
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
isc_nmhandle_unref(sock->outerhandle); isc_nmhandle_unref(sock->outerhandle);
sock->outerhandle = NULL; sock->outerhandle = NULL;
@@ -454,7 +454,7 @@ resume_processing(void *arg) {
* Nothing in the buffer; resume reading. * Nothing in the buffer; resume reading.
*/ */
if (sock->outerhandle != NULL) { if (sock->outerhandle != NULL) {
isc_nm_resumeread(sock->outerhandle->sock); isc_nm_resumeread(sock->outerhandle);
} }
break; break;

View File

@@ -457,7 +457,9 @@ isc_nm_listentcpdns
isc_nm_listentcp isc_nm_listentcp
isc_nm_listenudp isc_nm_listenudp
isc_nm_maxudp isc_nm_maxudp
isc_nm_pauseread
isc_nm_read isc_nm_read
isc_nm_resumeread
isc_nm_send isc_nm_send
isc_nm_setstats isc_nm_setstats
isc_nm_start isc_nm_start