]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
use handles for isc_nm_pauseread() and isc_nm_resumeread()
authorEvan Hunt <each@isc.org>
Wed, 1 Jul 2020 23:17:09 +0000 (16:17 -0700)
committerOndřej Surý <ondrej@isc.org>
Thu, 1 Oct 2020 14:44:43 +0000 (16:44 +0200)
by having these functions act on netmgr handles instead of socket
objects, they can be used in callback functions outside the netgmr.

(cherry picked from commit 55896df79d9f537577834375cb21676e8176b5ed)

lib/isc/include/isc/netmgr.h
lib/isc/netmgr/netmgr.c
lib/isc/netmgr/tcpdns.c
lib/isc/win32/libisc.def.in

index 14b8b2b648f21f204a961c37fc2585d9db939538..21a303e23ba921d79912a44d632349f930313df3 100644 (file)
@@ -204,9 +204,12 @@ isc_result_t
 isc_nm_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb, void *cbarg);
 
 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
@@ -221,13 +224,13 @@ isc_nm_cancelread(isc_nmhandle_t *handle);
  */
 
 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:
- * \li 'sock' is a valid netmgr socket
- * \li ...for which a read/recv callback has been defined.
+ * \li 'handle' is a valid netmgr handle.
+ * \li ...for a socket with a defined read/recv callback.
  */
 
 isc_result_t
index 9be36f28d23716d3eca53a0a0ecca2b7c7bd6d9f..aef7aa145b1c85f63b566132cb3a515fe0b12a20 100644 (file)
@@ -1379,8 +1379,10 @@ isc_nm_cancelread(isc_nmhandle_t *handle) {
 }
 
 isc_result_t
-isc_nm_pauseread(isc_nmsocket_t *sock) {
-       REQUIRE(VALID_NMSOCK(sock));
+isc_nm_pauseread(isc_nmhandle_t *handle) {
+       REQUIRE(VALID_NMHANDLE(handle));
+
+       isc_nmsocket_t *sock = handle->sock;
 
        switch (sock->type) {
        case isc_nm_tcpsocket:
@@ -1392,8 +1394,10 @@ isc_nm_pauseread(isc_nmsocket_t *sock) {
 }
 
 isc_result_t
-isc_nm_resumeread(isc_nmsocket_t *sock) {
-       REQUIRE(VALID_NMSOCK(sock));
+isc_nm_resumeread(isc_nmhandle_t *handle) {
+       REQUIRE(VALID_NMHANDLE(handle));
+
+       isc_nmsocket_t *sock = handle->sock;
 
        switch (sock->type) {
        case isc_nm_tcpsocket:
index 544fd09771d7c4bbd4baf24914966d6cae6f4d34..81d07013aeae85fbd536ba093aaa28eb26e7fdfa 100644 (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
                         * completes.
                         */
-                       isc_nm_pauseread(dnssock->outerhandle->sock);
+                       isc_nm_pauseread(dnssock->outerhandle);
                        done = true;
                } else {
                        /*
@@ -295,7 +295,7 @@ dnslisten_readcb(isc_nmhandle_t *handle, isc_result_t eresult,
                         */
                        if (atomic_load(&dnssock->ah) >=
                            TCPDNS_CLIENTS_PER_CONN) {
-                               isc_nm_pauseread(dnssock->outerhandle->sock);
+                               isc_nm_pauseread(dnssock->outerhandle);
                                done = true;
                        }
                }
@@ -376,7 +376,7 @@ isc_nm_tcpdns_sequential(isc_nmhandle_t *handle) {
         * closehandle_cb callback, called whenever a handle
         * is released.
         */
-       isc_nm_pauseread(handle->sock->outerhandle->sock);
+       isc_nm_pauseread(handle->sock->outerhandle);
        atomic_store(&handle->sock->sequential, true);
 }
 
@@ -431,7 +431,7 @@ resume_processing(void *arg) {
                        }
                        isc_nmhandle_unref(handle);
                } else if (sock->outerhandle != NULL) {
-                       result = isc_nm_resumeread(sock->outerhandle->sock);
+                       result = isc_nm_resumeread(sock->outerhandle);
                        if (result != ISC_R_SUCCESS) {
                                isc_nmhandle_unref(sock->outerhandle);
                                sock->outerhandle = NULL;
@@ -454,7 +454,7 @@ resume_processing(void *arg) {
                         * Nothing in the buffer; resume reading.
                         */
                        if (sock->outerhandle != NULL) {
-                               isc_nm_resumeread(sock->outerhandle->sock);
+                               isc_nm_resumeread(sock->outerhandle);
                        }
 
                        break;
index d51ce4570e7e867835dd5c31f2cd714b9e449dc4..22ec9abfe2661fbd7b3a39de1f3412631cb3e74b 100644 (file)
@@ -461,7 +461,9 @@ isc_nm_listentcpdns
 isc_nm_listentcp
 isc_nm_listenudp
 isc_nm_maxudp
+isc_nm_pauseread
 isc_nm_read
+isc_nm_resumeread
 isc_nm_send
 isc_nm_setstats
 isc_nm_start