]> 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)
committerEvan Hunt <each@isc.org>
Mon, 13 Jul 2020 20:17:08 +0000 (13:17 -0700)
by having these functions act on netmgr handles instead of socket
objects, they can be used in callback functions outside the netgmr.

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

index 99d41f01f4850b42ffa93c203b77ad978cab7be3..3f6d8f6f05b9f9bd1be4fb75f96ee8dd0d7ee533 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 432d612dbebaf5f66928fdfb3d75955e49265fcc..0cdf5b3e9cd749118bdcb1572ab2f0b147957130 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 05cc410d6830a82abe8915c1a058ea012b1d5c4e..512f88be031eca414bfb690399099e814105dc07 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 7313a73acb258e0ac7292e8ff57b6a307ba9b0ef..102a2263ed654161430c25d29b13b3be30c6adeb 100644 (file)
@@ -457,7 +457,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