From 31b3980ef07a3809dcda54f17795d7e2895f5bc2 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Mon, 9 Dec 2019 12:24:46 -0800 Subject: [PATCH] shorten some names reduce line breaks and general unwieldiness by changing some function, type, and parameter names. --- lib/isc/netmgr/netmgr-int.h | 46 ++++++++++++-------------- lib/isc/netmgr/netmgr.c | 20 ++++++------ lib/isc/netmgr/tcp.c | 64 ++++++++++++++++--------------------- lib/isc/netmgr/tcpdns.c | 4 +-- lib/isc/netmgr/udp.c | 27 +++++++--------- 5 files changed, 72 insertions(+), 89 deletions(-) diff --git a/lib/isc/netmgr/netmgr-int.h b/lib/isc/netmgr/netmgr-int.h index bed5622f8b..daae5fd880 100644 --- a/lib/isc/netmgr/netmgr-int.h +++ b/lib/isc/netmgr/netmgr-int.h @@ -115,12 +115,12 @@ typedef enum isc__netievent_type { netievent_tcpstartread, netievent_tcppauseread, netievent_tcpchildlisten, - netievent_tcpstopchildlisten, + netievent_tcpchildstop, netievent_closecb, netievent_shutdown, netievent_stop, - netievent_udpstoplisten, - netievent_tcpstoplisten, + netievent_udpstop, + netievent_tcpstop, netievent_tcpclose, netievent_tcpdnsclose, netievent_prio = 0xff, /* event type values higher than this @@ -192,9 +192,9 @@ typedef struct isc__netievent__socket { } isc__netievent__socket_t; typedef isc__netievent__socket_t isc__netievent_udplisten_t; -typedef isc__netievent__socket_t isc__netievent_udpstoplisten_t; -typedef isc__netievent__socket_t isc__netievent_tcpstoplisten_t; -typedef isc__netievent__socket_t isc__netievent_tcpstopchildlisten_t; +typedef isc__netievent__socket_t isc__netievent_udpstop_t; +typedef isc__netievent__socket_t isc__netievent_tcpstop_t; +typedef isc__netievent__socket_t isc__netievent_tcpchildstop_t; typedef isc__netievent__socket_t isc__netievent_tcpclose_t; typedef isc__netievent__socket_t isc__netievent_tcpdnsclose_t; typedef isc__netievent__socket_t isc__netievent_startread_t; @@ -566,13 +566,13 @@ isc__nmsocket_prep_destroy(isc_nmsocket_t *sock); */ void -isc__nm_async_closecb(isc__networker_t *worker, isc__netievent_t *ievent0); +isc__nm_async_closecb(isc__networker_t *worker, isc__netievent_t *ev0); /*%< * Issue a 'handle closed' callback on the socket. */ void -isc__nm_async_shutdown(isc__networker_t *worker, isc__netievent_t *ievent0); +isc__nm_async_shutdown(isc__networker_t *worker, isc__netievent_t *ev0); /*%< * Walk through all uv handles, get the underlying sockets and issue * close on them. @@ -586,13 +586,12 @@ isc__nm_udp_send(isc_nmhandle_t *handle, isc_region_t *region, */ void -isc__nm_async_udplisten(isc__networker_t *worker, isc__netievent_t *ievent0); +isc__nm_async_udplisten(isc__networker_t *worker, isc__netievent_t *ev0); void -isc__nm_async_udpstoplisten(isc__networker_t *worker, - isc__netievent_t *ievent0); +isc__nm_async_udpstop(isc__networker_t *worker, isc__netievent_t *ev0); void -isc__nm_async_udpsend(isc__networker_t *worker, isc__netievent_t *ievent0); +isc__nm_async_udpsend(isc__networker_t *worker, isc__netievent_t *ev0); /*%< * Callback handlers for asynchronous UDP events (listen, stoplisten, send). */ @@ -617,26 +616,23 @@ isc__nm_tcp_shutdown(isc_nmsocket_t *sock); */ void -isc__nm_async_tcpconnect(isc__networker_t *worker, isc__netievent_t *ievent0); +isc__nm_async_tcpconnect(isc__networker_t *worker, isc__netievent_t *ev0); void -isc__nm_async_tcplisten(isc__networker_t *worker, isc__netievent_t *ievent0); +isc__nm_async_tcplisten(isc__networker_t *worker, isc__netievent_t *ev0); void -isc__nm_async_tcpchildlisten(isc__networker_t *worker, - isc__netievent_t *ievent0); +isc__nm_async_tcpchildlisten(isc__networker_t *worker, isc__netievent_t *ev0); void -isc__nm_async_tcpstoplisten(isc__networker_t *worker, - isc__netievent_t *ievent0); +isc__nm_async_tcpstop(isc__networker_t *worker, isc__netievent_t *ev0); void -isc__nm_async_tcpstopchildlisten(isc__networker_t *worker, - isc__netievent_t *ievent0); +isc__nm_async_tcpchildstop(isc__networker_t *worker, isc__netievent_t *ev0); void -isc__nm_async_tcpsend(isc__networker_t *worker, isc__netievent_t *ievent0); +isc__nm_async_tcpsend(isc__networker_t *worker, isc__netievent_t *ev0); void -isc__nm_async_startread(isc__networker_t *worker, isc__netievent_t *ievent0); +isc__nm_async_startread(isc__networker_t *worker, isc__netievent_t *ev0); void -isc__nm_async_pauseread(isc__networker_t *worker, isc__netievent_t *ievent0); +isc__nm_async_pauseread(isc__networker_t *worker, isc__netievent_t *ev0); void -isc__nm_async_tcpclose(isc__networker_t *worker, isc__netievent_t *ievent0); +isc__nm_async_tcpclose(isc__networker_t *worker, isc__netievent_t *ev0); /*%< * Callback handlers for asynchronous TCP events (connect, listen, * stoplisten, send, read, pause, close). @@ -656,7 +652,7 @@ isc__nm_tcpdns_close(isc_nmsocket_t *sock); */ void -isc__nm_async_tcpdnsclose(isc__networker_t *worker, isc__netievent_t *ievent0); +isc__nm_async_tcpdnsclose(isc__networker_t *worker, isc__netievent_t *ev0); #define isc__nm_uverr2result(x) \ isc___nm_uverr2result(x, true, __FILE__, __LINE__) diff --git a/lib/isc/netmgr/netmgr.c b/lib/isc/netmgr/netmgr.c index 7964d55c72..0c1cba4561 100644 --- a/lib/isc/netmgr/netmgr.c +++ b/lib/isc/netmgr/netmgr.c @@ -525,8 +525,8 @@ process_queue(isc__networker_t *worker, isc_queue_t *queue) { case netievent_udplisten: isc__nm_async_udplisten(worker, ievent); break; - case netievent_udpstoplisten: - isc__nm_async_udpstoplisten(worker, ievent); + case netievent_udpstop: + isc__nm_async_udpstop(worker, ievent); break; case netievent_udpsend: isc__nm_async_udpsend(worker, ievent); @@ -549,11 +549,11 @@ process_queue(isc__networker_t *worker, isc_queue_t *queue) { case netievent_tcpsend: isc__nm_async_tcpsend(worker, ievent); break; - case netievent_tcpstoplisten: - isc__nm_async_tcpstoplisten(worker, ievent); + case netievent_tcpstop: + isc__nm_async_tcpstop(worker, ievent); break; - case netievent_tcpstopchildlisten: - isc__nm_async_tcpstopchildlisten(worker, ievent); + case netievent_tcpchildstop: + isc__nm_async_tcpchildstop(worker, ievent); break; case netievent_tcpclose: isc__nm_async_tcpclose(worker, ievent); @@ -1238,9 +1238,9 @@ isc_nm_send(isc_nmhandle_t *handle, isc_region_t *region, } void -isc__nm_async_closecb(isc__networker_t *worker, isc__netievent_t *ievent0) { +isc__nm_async_closecb(isc__networker_t *worker, isc__netievent_t *ev0) { isc__netievent_closecb_t *ievent = - (isc__netievent_closecb_t *) ievent0; + (isc__netievent_closecb_t *) ev0; REQUIRE(VALID_NMSOCK(ievent->sock)); REQUIRE(ievent->sock->tid == isc_nm_tid()); @@ -1268,8 +1268,8 @@ shutdown_walk_cb(uv_handle_t *handle, void *arg) { } void -isc__nm_async_shutdown(isc__networker_t *worker, isc__netievent_t *ievent0) { - UNUSED(ievent0); +isc__nm_async_shutdown(isc__networker_t *worker, isc__netievent_t *ev0) { + UNUSED(ev0); uv_walk(&worker->loop, shutdown_walk_cb, NULL); } diff --git a/lib/isc/netmgr/tcp.c b/lib/isc/netmgr/tcp.c index 4567f9343a..a996acfb01 100644 --- a/lib/isc/netmgr/tcp.c +++ b/lib/isc/netmgr/tcp.c @@ -95,9 +95,9 @@ tcp_connect_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) { } void -isc__nm_async_tcpconnect(isc__networker_t *worker, isc__netievent_t *ievent0) { +isc__nm_async_tcpconnect(isc__networker_t *worker, isc__netievent_t *ev0) { isc__netievent_tcpconnect_t *ievent = - (isc__netievent_tcpconnect_t *) ievent0; + (isc__netievent_tcpconnect_t *) ev0; isc_nmsocket_t *sock = ievent->sock; isc__nm_uvreq_t *req = ievent->req; int r; @@ -234,9 +234,9 @@ syncdir(const isc_nmsocket_t *sock) { * they have been deprecated and removed.) */ void -isc__nm_async_tcplisten(isc__networker_t *worker, isc__netievent_t *ievent0) { +isc__nm_async_tcplisten(isc__networker_t *worker, isc__netievent_t *ev0) { isc__netievent_tcplisten_t *ievent = - (isc__netievent_tcplisten_t *) ievent0; + (isc__netievent_tcplisten_t *) ev0; isc_nmsocket_t *sock = ievent->sock; int r; @@ -407,11 +407,9 @@ ipc_close_cb(uv_handle_t *handle) { * for the socket we'll be listening on. */ void -isc__nm_async_tcpchildlisten(isc__networker_t *worker, - isc__netievent_t *ievent0) -{ - isc__netievent_tcplisten_t *ievent = - (isc__netievent_tcplisten_t *) ievent0; +isc__nm_async_tcpchildlisten(isc__networker_t *worker, isc__netievent_t *ev0) { + isc__netievent_tcpchildlisten_t *ievent = + (isc__netievent_tcpchildlisten_t *) ev0; isc_nmsocket_t *sock = ievent->sock; isc__nm_uvreq_t *req = NULL; int r; @@ -488,23 +486,20 @@ childlisten_read_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) { void isc_nm_tcp_stoplistening(isc_nmsocket_t *sock) { - isc__netievent_tcpstoplisten_t *ievent = NULL; + isc__netievent_tcpstop_t *ievent = NULL; REQUIRE(VALID_NMSOCK(sock)); REQUIRE(!isc__nm_in_netthread()); - ievent = isc__nm_get_ievent(sock->mgr, netievent_tcpstoplisten); + ievent = isc__nm_get_ievent(sock->mgr, netievent_tcpstop); isc_nmsocket_attach(sock, &ievent->sock); isc__nm_enqueue_ievent(&sock->mgr->workers[sock->tid], (isc__netievent_t *) ievent); } void -isc__nm_async_tcpstoplisten(isc__networker_t *worker, - isc__netievent_t *ievent0) -{ - isc__netievent_tcpstoplisten_t *ievent = - (isc__netievent_tcpstoplisten_t *) ievent0; +isc__nm_async_tcpstop(isc__networker_t *worker, isc__netievent_t *ev0) { + isc__netievent_tcpstop_t *ievent = (isc__netievent_tcpstop_t *) ev0; isc_nmsocket_t *sock = ievent->sock; UNUSED(worker); @@ -517,10 +512,10 @@ isc__nm_async_tcpstoplisten(isc__networker_t *worker, * If network manager is interlocked, re-enqueue the event for later. */ if (!isc__nm_acquire_interlocked(sock->mgr)) { - isc__netievent_tcpstoplisten_t *event = NULL; + isc__netievent_tcpstop_t *event = NULL; event = isc__nm_get_ievent(sock->mgr, - netievent_tcpstoplisten); + netievent_tcpstop); event->sock = sock; isc__nm_enqueue_ievent(&sock->mgr->workers[sock->tid], (isc__netievent_t *) event); @@ -533,20 +528,18 @@ isc__nm_async_tcpstoplisten(isc__networker_t *worker, static void stoplistening(isc_nmsocket_t *sock) { for (int i = 0; i < sock->nchildren; i++) { - isc__netievent_tcpstopchildlisten_t *event = NULL; + isc__netievent_tcpchildstop_t *event = NULL; /* * We can ignore the overhead of event allocation because * stoplistening is a rare event, and doing it this way * simplifies sock reference counting. */ - event = isc__nm_get_ievent(sock->mgr, - netievent_tcpstopchildlisten); + event = isc__nm_get_ievent(sock->mgr, netievent_tcpchildstop); isc_nmsocket_attach(&sock->children[i], &event->sock); if (i == sock->tid) { - isc__nm_async_tcpstopchildlisten( - &sock->mgr->workers[i], + isc__nm_async_tcpchildstop(&sock->mgr->workers[i], (isc__netievent_t *) event); isc__nm_put_ievent(sock->mgr, event); } else { @@ -564,11 +557,9 @@ stoplistening(isc_nmsocket_t *sock) { } void -isc__nm_async_tcpstopchildlisten(isc__networker_t *worker, - isc__netievent_t *ievent0) -{ - isc__netievent_tcpstoplisten_t *ievent = - (isc__netievent_tcpstoplisten_t *) ievent0; +isc__nm_async_tcpchildstop(isc__networker_t *worker, isc__netievent_t *ev0) { + isc__netievent_tcpchildstop_t *ievent = + (isc__netievent_tcpchildstop_t *) ev0; isc_nmsocket_t *sock = ievent->sock; UNUSED(worker); @@ -665,9 +656,9 @@ isc_nm_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb, void *cbarg) { } void -isc__nm_async_startread(isc__networker_t *worker, isc__netievent_t *ievent0) { +isc__nm_async_startread(isc__networker_t *worker, isc__netievent_t *ev0) { isc__netievent_startread_t *ievent = - (isc__netievent_startread_t *) ievent0; + (isc__netievent_startread_t *) ev0; isc_nmsocket_t *sock = ievent->sock; REQUIRE(worker->id == isc_nm_tid()); @@ -711,9 +702,9 @@ isc_nm_pauseread(isc_nmsocket_t *sock) { } void -isc__nm_async_pauseread(isc__networker_t *worker, isc__netievent_t *ievent0) { +isc__nm_async_pauseread(isc__networker_t *worker, isc__netievent_t *ev0) { isc__netievent_pauseread_t *ievent = - (isc__netievent_pauseread_t *) ievent0; + (isc__netievent_pauseread_t *) ev0; isc_nmsocket_t *sock = ievent->sock; REQUIRE(VALID_NMSOCK(sock)); @@ -957,9 +948,9 @@ tcp_send_cb(uv_write_t *req, int status) { * Handle 'tcpsend' async event - send a packet on the socket */ void -isc__nm_async_tcpsend(isc__networker_t *worker, isc__netievent_t *ievent0) { +isc__nm_async_tcpsend(isc__networker_t *worker, isc__netievent_t *ev0) { isc_result_t result; - isc__netievent_tcpsend_t *ievent = (isc__netievent_tcpsend_t *) ievent0; + isc__netievent_tcpsend_t *ievent = (isc__netievent_tcpsend_t *) ev0; REQUIRE(worker->id == ievent->sock->tid); @@ -1064,9 +1055,8 @@ isc__nm_tcp_close(isc_nmsocket_t *sock) { } void -isc__nm_async_tcpclose(isc__networker_t *worker, isc__netievent_t *ievent0) { - isc__netievent_tcpclose_t *ievent = - (isc__netievent_tcpclose_t *) ievent0; +isc__nm_async_tcpclose(isc__networker_t *worker, isc__netievent_t *ev0) { + isc__netievent_tcpclose_t *ievent = (isc__netievent_tcpclose_t *) ev0; REQUIRE(worker->id == ievent->sock->tid); diff --git a/lib/isc/netmgr/tcpdns.c b/lib/isc/netmgr/tcpdns.c index 94fb021bc6..5048200aca 100644 --- a/lib/isc/netmgr/tcpdns.c +++ b/lib/isc/netmgr/tcpdns.c @@ -523,9 +523,9 @@ isc__nm_tcpdns_close(isc_nmsocket_t *sock) { } void -isc__nm_async_tcpdnsclose(isc__networker_t *worker, isc__netievent_t *ievent0) { +isc__nm_async_tcpdnsclose(isc__networker_t *worker, isc__netievent_t *ev0) { isc__netievent_tcpdnsclose_t *ievent = - (isc__netievent_tcpdnsclose_t *) ievent0; + (isc__netievent_tcpdnsclose_t *) ev0; REQUIRE(worker->id == ievent->sock->tid); diff --git a/lib/isc/netmgr/udp.c b/lib/isc/netmgr/udp.c index 102ff0dbda..abd950a279 100644 --- a/lib/isc/netmgr/udp.c +++ b/lib/isc/netmgr/udp.c @@ -115,9 +115,9 @@ isc_nm_listenudp(isc_nm_t *mgr, isc_nmiface_t *iface, * handle 'udplisten' async call - start listening on a socket. */ void -isc__nm_async_udplisten(isc__networker_t *worker, isc__netievent_t *ievent0) { +isc__nm_async_udplisten(isc__networker_t *worker, isc__netievent_t *ev0) { isc__netievent_udplisten_t *ievent = - (isc__netievent_udplisten_t *) ievent0; + (isc__netievent_udplisten_t *) ev0; isc_nmsocket_t *sock = ievent->sock; REQUIRE(sock->type == isc_nm_udpsocket); @@ -173,14 +173,14 @@ stoplistening(isc_nmsocket_t *sock) { INSIST(sock->type == isc_nm_udplistener); for (int i = 0; i < sock->nchildren; i++) { - isc__netievent_udpstoplisten_t *event = NULL; + isc__netievent_udpstop_t *event = NULL; if (i == sock->tid) { stop_udp_child(&sock->children[i]); continue; } - event = isc__nm_get_ievent(sock->mgr, netievent_udpstoplisten); + event = isc__nm_get_ievent(sock->mgr, netievent_udpstop); event->sock = &sock->children[i]; isc__nm_enqueue_ievent(&sock->mgr->workers[i], (isc__netievent_t *) event); @@ -198,7 +198,7 @@ stoplistening(isc_nmsocket_t *sock) { void isc_nm_udp_stoplistening(isc_nmsocket_t *sock) { - isc__netievent_udpstoplisten_t *ievent = NULL; + isc__netievent_udpstop_t *ievent = NULL; /* We can't be launched from network thread, we'd deadlock */ REQUIRE(!isc__nm_in_netthread()); @@ -210,7 +210,7 @@ isc_nm_udp_stoplistening(isc_nmsocket_t *sock) { * event. Otherwise, go ahead and stop listening right away. */ if (!isc__nm_acquire_interlocked(sock->mgr)) { - ievent = isc__nm_get_ievent(sock->mgr, netievent_udpstoplisten); + ievent = isc__nm_get_ievent(sock->mgr, netievent_udpstop); ievent->sock = sock; isc__nm_enqueue_ievent(&sock->mgr->workers[sock->tid], (isc__netievent_t *) ievent); @@ -221,14 +221,11 @@ isc_nm_udp_stoplistening(isc_nmsocket_t *sock) { } /* - * handle 'udpstoplisten' async call - stop listening on a socket. + * handle 'udpstop' async call - stop listening on a socket. */ void -isc__nm_async_udpstoplisten(isc__networker_t *worker, - isc__netievent_t *ievent0) -{ - isc__netievent_udplisten_t *ievent = - (isc__netievent_udplisten_t *) ievent0; +isc__nm_async_udpstop(isc__networker_t *worker, isc__netievent_t *ev0) { + isc__netievent_udpstop_t *ievent = (isc__netievent_udpstop_t *) ev0; isc_nmsocket_t *sock = ievent->sock; REQUIRE(sock->iface != NULL); @@ -248,7 +245,7 @@ isc__nm_async_udpstoplisten(isc__networker_t *worker, if (!isc__nm_acquire_interlocked(sock->mgr)) { isc__netievent_udplisten_t *event = NULL; - event = isc__nm_get_ievent(sock->mgr, netievent_udpstoplisten); + event = isc__nm_get_ievent(sock->mgr, netievent_udpstop); event->sock = sock; isc__nm_enqueue_ievent(&sock->mgr->workers[sock->tid], (isc__netievent_t *) event); @@ -407,9 +404,9 @@ isc__nm_udp_send(isc_nmhandle_t *handle, isc_region_t *region, * handle 'udpsend' async event - send a packet on the socket */ void -isc__nm_async_udpsend(isc__networker_t *worker, isc__netievent_t *ievent0) { +isc__nm_async_udpsend(isc__networker_t *worker, isc__netievent_t *ev0) { isc__netievent_udpsend_t *ievent = - (isc__netievent_udpsend_t *) ievent0; + (isc__netievent_udpsend_t *) ev0; REQUIRE(worker->id == ievent->sock->tid);