tcpdns used transport-specific functions to operate on the outer socket.
Use generic ones instead, and select the proper call in netmgr.c.
Make the missing functions (e.g. isc_nm_read) generic and add type-specific
calls (isc__nm_tcp_read). This is the preparation for netmgr TLS layer.
*/
void
-isc_nm_udp_stoplistening(isc_nmsocket_t *sock);
+isc_nm_stoplistening(isc_nmsocket_t *sock);
/*%<
- * Stop listening for UDP packets on socket 'sock'.
+ * Stop listening on socket 'sock'.
*/
void
* prepended with a two-byte length field, and handles buffering.
*/
-void
-isc_nm_tcp_stoplistening(isc_nmsocket_t *sock);
-/*%<
- * Stop listening on TCP socket 'sock'.
- */
-
isc_result_t
isc_nm_listentcpdns(isc_nm_t *mgr, isc_nmiface_t *iface, isc_nm_recv_cb_t cb,
void *cbarg, isc_nm_cb_t accept_cb, void *accept_cbarg,
* 'quota' is passed to isc_nm_listentcp() when opening the raw TCP socket.
*/
-void
-isc_nm_tcpdns_stoplistening(isc_nmsocket_t *sock);
-/*%<
- * Stop listening on TCPDNS socket 'sock'.
- */
-
void
isc_nm_tcpdns_sequential(isc_nmhandle_t *handle);
/*%<
typedef enum isc__netievent_type {
netievent_udpsend,
netievent_udprecv,
+ netievent_udpstop,
+
netievent_tcpconnect,
netievent_tcpsend,
netievent_tcprecv,
netievent_tcppauseread,
netievent_tcpchildlisten,
netievent_tcpchildstop,
- netievent_closecb,
- netievent_shutdown,
- netievent_stop,
- netievent_udpstop,
netievent_tcpstop,
netievent_tcpclose,
netievent_tcpdnsclose,
+
+ netievent_closecb,
+ netievent_shutdown,
+ netievent_stop,
netievent_prio = 0xff, /* event type values higher than this
* will be treated as high-priority
* events, which can be processed
* Back-end implementation of isc_nm_send() for UDP handles.
*/
+void
+isc__nm_udp_stoplistening(isc_nmsocket_t *sock);
+
void
isc__nm_async_udplisten(isc__networker_t *worker, isc__netievent_t *ev0);
* Back-end implementation of isc_nm_send() for TCP handles.
*/
+isc_result_t
+isc__nm_tcp_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb, void *cbarg);
+
void
isc__nm_tcp_close(isc_nmsocket_t *sock);
/*%<
* Close a TCP socket.
*/
+isc_result_t
+isc__nm_tcp_pauseread(isc_nmsocket_t *sock);
+/*%<
+ * Pause reading on this socket, while still remembering the callback.
+ */
+
+isc_result_t
+isc__nm_tcp_resumeread(isc_nmsocket_t *sock);
+/*%<
+ * Resume reading from socket.
+ *
+ */
void
isc__nm_tcp_shutdown(isc_nmsocket_t *sock);
* Called on shutdown to close and clean up a listening TCP socket.
*/
+void
+isc__nm_tcp_stoplistening(isc_nmsocket_t *sock);
+
void
isc__nm_async_tcpconnect(isc__networker_t *worker, isc__netievent_t *ev0);
void
void
isc__nm_async_pauseread(isc__networker_t *worker, isc__netievent_t *ev0);
void
+isc__nm_async_tcp_startread(isc__networker_t *worker, isc__netievent_t *ev0);
+void
+isc__nm_async_tcp_pauseread(isc__networker_t *worker, isc__netievent_t *ev0);
+void
isc__nm_async_tcpclose(isc__networker_t *worker, isc__netievent_t *ev0);
/*%<
* Callback handlers for asynchronous TCP events (connect, listen,
* Close a TCPDNS socket.
*/
+void
+isc__nm_tcpdns_stoplistening(isc_nmsocket_t *sock);
+
void
isc__nm_async_tcpdnsclose(isc__networker_t *worker, isc__netievent_t *ev0);
isc__nm_async_tcpchildlisten(worker, ievent);
break;
case netievent_tcpstartread:
- isc__nm_async_startread(worker, ievent);
+ isc__nm_async_tcp_startread(worker, ievent);
break;
case netievent_tcppauseread:
- isc__nm_async_pauseread(worker, ievent);
+ isc__nm_async_tcp_pauseread(worker, ievent);
break;
case netievent_tcpsend:
isc__nm_async_tcpsend(worker, ievent);
}
}
+isc_result_t
+isc_nm_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb, void *cbarg) {
+ REQUIRE(VALID_NMHANDLE(handle));
+
+ switch (handle->sock->type) {
+ case isc_nm_tcpsocket:
+ return (isc__nm_tcp_read(handle, cb, cbarg));
+ default:
+ INSIST(0);
+ ISC_UNREACHABLE();
+ }
+}
+
+isc_result_t
+isc_nm_pauseread(isc_nmsocket_t *sock) {
+ REQUIRE(VALID_NMSOCK(sock));
+ switch (sock->type) {
+ case isc_nm_tcpsocket:
+ return (isc__nm_tcp_pauseread(sock));
+ default:
+ INSIST(0);
+ ISC_UNREACHABLE();
+ }
+}
+
+isc_result_t
+isc_nm_resumeread(isc_nmsocket_t *sock) {
+ REQUIRE(VALID_NMSOCK(sock));
+ switch (sock->type) {
+ case isc_nm_tcpsocket:
+ return (isc__nm_tcp_resumeread(sock));
+ default:
+ INSIST(0);
+ ISC_UNREACHABLE();
+ }
+}
+
+void
+isc_nm_stoplistening(isc_nmsocket_t *sock) {
+ REQUIRE(VALID_NMSOCK(sock));
+ switch (sock->type) {
+ case isc_nm_udplistener:
+ isc__nm_udp_stoplistening(sock);
+ break;
+ case isc_nm_tcpdnslistener:
+ isc__nm_tcpdns_stoplistening(sock);
+ break;
+ case isc_nm_tcplistener:
+ isc__nm_tcp_stoplistening(sock);
+ break;
+ default:
+ INSIST(0);
+ ISC_UNREACHABLE();
+ }
+}
+
void
isc__nm_async_closecb(isc__networker_t *worker, isc__netievent_t *ev0) {
isc__netievent_closecb_t *ievent = (isc__netievent_closecb_t *)ev0;
}
void
-isc_nm_tcp_stoplistening(isc_nmsocket_t *sock) {
+isc__nm_tcp_stoplistening(isc_nmsocket_t *sock) {
isc__netievent_tcpstop_t *ievent = NULL;
REQUIRE(VALID_NMSOCK(sock));
}
isc_result_t
-isc_nm_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb, void *cbarg) {
+isc__nm_tcp_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb, void *cbarg) {
isc_nmsocket_t *sock = NULL;
isc__netievent_startread_t *ievent = NULL;
ievent->sock = sock;
if (sock->tid == isc_nm_tid()) {
- isc__nm_async_startread(&sock->mgr->workers[sock->tid],
- (isc__netievent_t *)ievent);
+ isc__nm_async_tcp_startread(&sock->mgr->workers[sock->tid],
+ (isc__netievent_t *)ievent);
isc__nm_put_ievent(sock->mgr, ievent);
} else {
isc__nm_enqueue_ievent(&sock->mgr->workers[sock->tid],
}
void
-isc__nm_async_startread(isc__networker_t *worker, isc__netievent_t *ev0) {
+isc__nm_async_tcp_startread(isc__networker_t *worker, isc__netievent_t *ev0) {
isc__netievent_startread_t *ievent = (isc__netievent_startread_t *)ev0;
isc_nmsocket_t *sock = ievent->sock;
int r;
}
isc_result_t
-isc_nm_pauseread(isc_nmsocket_t *sock) {
+isc__nm_tcp_pauseread(isc_nmsocket_t *sock) {
isc__netievent_pauseread_t *ievent = NULL;
REQUIRE(VALID_NMSOCK(sock));
ievent->sock = sock;
if (sock->tid == isc_nm_tid()) {
- isc__nm_async_pauseread(&sock->mgr->workers[sock->tid],
- (isc__netievent_t *)ievent);
+ isc__nm_async_tcp_pauseread(&sock->mgr->workers[sock->tid],
+ (isc__netievent_t *)ievent);
isc__nm_put_ievent(sock->mgr, ievent);
} else {
isc__nm_enqueue_ievent(&sock->mgr->workers[sock->tid],
}
void
-isc__nm_async_pauseread(isc__networker_t *worker, isc__netievent_t *ev0) {
+isc__nm_async_tcp_pauseread(isc__networker_t *worker, isc__netievent_t *ev0) {
isc__netievent_pauseread_t *ievent = (isc__netievent_pauseread_t *)ev0;
isc_nmsocket_t *sock = ievent->sock;
}
isc_result_t
-isc_nm_resumeread(isc_nmsocket_t *sock) {
+isc__nm_tcp_resumeread(isc_nmsocket_t *sock) {
isc__netievent_startread_t *ievent = NULL;
REQUIRE(VALID_NMSOCK(sock));
ievent->sock = sock;
if (sock->tid == isc_nm_tid()) {
- isc__nm_async_startread(&sock->mgr->workers[sock->tid],
- (isc__netievent_t *)ievent);
+ isc__nm_async_tcp_startread(&sock->mgr->workers[sock->tid],
+ (isc__netievent_t *)ievent);
isc__nm_put_ievent(sock->mgr, ievent);
} else {
isc__nm_enqueue_ievent(&sock->mgr->workers[sock->tid],
}
void
-isc_nm_tcpdns_stoplistening(isc_nmsocket_t *sock) {
+isc__nm_tcpdns_stoplistening(isc_nmsocket_t *sock) {
REQUIRE(VALID_NMSOCK(sock));
REQUIRE(sock->type == isc_nm_tcpdnslistener);
sock->rcbarg = NULL;
if (sock->outer != NULL) {
- isc_nm_tcp_stoplistening(sock->outer);
+ isc_nm_stoplistening(sock->outer);
isc_nmsocket_detach(&sock->outer);
}
}
*(uint16_t *)t->region.base = htons(region->length);
memmove(t->region.base + 2, region->base, region->length);
- return (isc__nm_tcp_send(t->handle, &t->region, tcpdnssend_cb, t));
+ return (isc_nm_send(t->handle, &t->region, tcpdnssend_cb, t));
}
static void
}
void
-isc_nm_udp_stoplistening(isc_nmsocket_t *sock) {
+isc__nm_udp_stoplistening(isc_nmsocket_t *sock) {
isc__netievent_udpstop_t *ievent = NULL;
/* We can't be launched from network thread, we'd deadlock */
isc_nm_send
isc_nm_setstats
isc_nm_start
+isc_nm_stoplistening
isc_nm_tcp_gettimeouts
isc_nm_tcp_settimeouts
-isc_nmsocket_detach
isc_nm_tcpdns_keepalive
isc_nm_tcpdns_sequential
-isc_nm_tcpdns_stoplistening
isc_nm_tid
-isc_nm_udp_stoplistening
+isc_nmsocket_detach
isc__nm_acquire_interlocked
isc__nm_drop_interlocked
isc__nm_acquire_interlocked_force
void
ns_interface_shutdown(ns_interface_t *ifp) {
if (ifp->udplistensocket != NULL) {
- isc_nm_udp_stoplistening(ifp->udplistensocket);
+ isc_nm_stoplistening(ifp->udplistensocket);
isc_nmsocket_detach(&ifp->udplistensocket);
}
if (ifp->tcplistensocket != NULL) {
- isc_nm_tcpdns_stoplistening(ifp->tcplistensocket);
+ isc_nm_stoplistening(ifp->tcplistensocket);
isc_nmsocket_detach(&ifp->tcplistensocket);
}
if (ifp->clientmgr != NULL) {