2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 22:15:20 +00:00

apply the modified style

This commit is contained in:
Evan Hunt
2020-02-13 14:44:37 -08:00
parent 0255a97473
commit e851ed0bb5
669 changed files with 35995 additions and 42219 deletions

View File

@@ -32,36 +32,26 @@
#include "netmgr-int.h"
#include "uv-compat.h"
static int
tcp_connect_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req);
static int tcp_connect_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req);
static void
tcp_close_direct(isc_nmsocket_t *sock);
static void tcp_close_direct(isc_nmsocket_t *sock);
static isc_result_t
tcp_send_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req);
static void
tcp_connect_cb(uv_connect_t *uvreq, int status);
static isc_result_t tcp_send_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req);
static void tcp_connect_cb(uv_connect_t *uvreq, int status);
static void
tcp_connection_cb(uv_stream_t *server, int status);
static void tcp_connection_cb(uv_stream_t *server, int status);
static void
read_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf);
static void read_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf);
static void
tcp_close_cb(uv_handle_t *uvhandle);
static void tcp_close_cb(uv_handle_t *uvhandle);
static void
stoplistening(isc_nmsocket_t *sock);
static void
tcp_listenclose_cb(uv_handle_t *handle);
static void stoplistening(isc_nmsocket_t *sock);
static void tcp_listenclose_cb(uv_handle_t *handle);
static int
tcp_connect_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req)
{
tcp_connect_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
isc__networker_t *worker = NULL;
int r;
int r;
REQUIRE(isc__nm_in_netthread());
@@ -89,13 +79,12 @@ tcp_connect_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req)
}
void
isc__nm_async_tcpconnect(isc__networker_t *worker, isc__netievent_t *ev0)
{
isc__nm_async_tcpconnect(isc__networker_t *worker, isc__netievent_t *ev0) {
isc__netievent_tcpconnect_t *ievent =
(isc__netievent_tcpconnect_t *)ev0;
isc_nmsocket_t * sock = ievent->sock;
isc_nmsocket_t *sock = ievent->sock;
isc__nm_uvreq_t *req = ievent->req;
int r;
int r;
REQUIRE(sock->type == isc_nm_tcpsocket);
REQUIRE(worker->id == ievent->req->sock->mgr->workers[isc_nm_tid()].id);
@@ -108,17 +97,16 @@ isc__nm_async_tcpconnect(isc__networker_t *worker, isc__netievent_t *ev0)
}
static void
tcp_connect_cb(uv_connect_t *uvreq, int status)
{
tcp_connect_cb(uv_connect_t *uvreq, int status) {
isc__nm_uvreq_t *req = (isc__nm_uvreq_t *)uvreq->data;
isc_nmsocket_t * sock = NULL;
isc_nmsocket_t *sock = NULL;
sock = uv_handle_get_data((uv_handle_t *)uvreq->handle);
REQUIRE(VALID_UVREQ(req));
if (status == 0) {
isc_result_t result;
isc_nmhandle_t * handle = NULL;
isc_result_t result;
isc_nmhandle_t *handle = NULL;
struct sockaddr_storage ss;
isc__nm_incstats(sock->mgr, sock->statsindex[STATID_CONNECT]);
@@ -146,9 +134,8 @@ tcp_connect_cb(uv_connect_t *uvreq, int status)
isc_result_t
isc_nm_listentcp(isc_nm_t *mgr, isc_nmiface_t *iface, isc_nm_cb_t cb,
void *cbarg, size_t extrahandlesize, int backlog,
isc_quota_t *quota, isc_nmsocket_t **sockp)
{
isc_nmsocket_t * nsock = NULL;
isc_quota_t *quota, isc_nmsocket_t **sockp) {
isc_nmsocket_t *nsock = NULL;
isc__netievent_tcplisten_t *ievent = NULL;
REQUIRE(VALID_NM(mgr));
@@ -157,8 +144,8 @@ isc_nm_listentcp(isc_nm_t *mgr, isc_nmiface_t *iface, isc_nm_cb_t cb,
isc__nmsocket_init(nsock, mgr, isc_nm_tcplistener, iface);
nsock->nchildren = mgr->nworkers;
atomic_init(&nsock->rchildren, mgr->nworkers);
nsock->children =
isc_mem_get(mgr->mctx, mgr->nworkers * sizeof(*nsock));
nsock->children = isc_mem_get(mgr->mctx,
mgr->nworkers * sizeof(*nsock));
memset(nsock->children, 0, mgr->nworkers * sizeof(*nsock));
nsock->rcb.accept = cb;
nsock->rcbarg = cbarg;
@@ -215,12 +202,11 @@ isc_nm_listentcp(isc_nm_t *mgr, isc_nmiface_t *iface, isc_nm_cb_t cb,
* they have been deprecated and removed.)
*/
void
isc__nm_async_tcplisten(isc__networker_t *worker, isc__netievent_t *ev0)
{
isc__nm_async_tcplisten(isc__networker_t *worker, isc__netievent_t *ev0) {
isc__netievent_tcplisten_t *ievent = (isc__netievent_tcplisten_t *)ev0;
isc_nmsocket_t * sock = ievent->sock;
struct sockaddr_storage sname;
int r, flags = 0, snamelen = sizeof(sname);
isc_nmsocket_t *sock = ievent->sock;
struct sockaddr_storage sname;
int r, flags = 0, snamelen = sizeof(sname);
REQUIRE(isc__nm_in_netthread());
REQUIRE(sock->type == isc_nm_tcplistener);
@@ -291,7 +277,7 @@ isc__nm_async_tcplisten(isc__networker_t *worker, isc__netievent_t *ev0)
* the exported socket.
*/
for (int i = 0; i < sock->nchildren; i++) {
isc_nmsocket_t * csock = &sock->children[i];
isc_nmsocket_t *csock = &sock->children[i];
isc__netievent_tcpchildlisten_t *event = NULL;
event = isc__nm_get_ievent(csock->mgr,
@@ -331,12 +317,11 @@ done:
* for the socket we'll be listening on.
*/
void
isc__nm_async_tcpchildlisten(isc__networker_t *worker, isc__netievent_t *ev0)
{
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;
int r;
int r;
REQUIRE(isc__nm_in_netthread());
REQUIRE(sock->type == isc_nm_tcpchildlistener);
@@ -367,8 +352,7 @@ isc__nm_async_tcpchildlisten(isc__networker_t *worker, isc__netievent_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));
@@ -381,10 +365,9 @@ isc_nm_tcp_stoplistening(isc_nmsocket_t *sock)
}
void
isc__nm_async_tcpstop(isc__networker_t *worker, isc__netievent_t *ev0)
{
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;
isc_nmsocket_t *sock = ievent->sock;
UNUSED(worker);
@@ -409,8 +392,7 @@ isc__nm_async_tcpstop(isc__networker_t *worker, isc__netievent_t *ev0)
}
static void
stoplistening(isc_nmsocket_t *sock)
{
stoplistening(isc_nmsocket_t *sock) {
for (int i = 0; i < sock->nchildren; i++) {
isc__netievent_tcpchildstop_t *event = NULL;
@@ -441,8 +423,7 @@ stoplistening(isc_nmsocket_t *sock)
}
void
isc__nm_async_tcpchildstop(isc__networker_t *worker, isc__netievent_t *ev0)
{
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;
@@ -472,11 +453,10 @@ isc__nm_async_tcpchildstop(isc__networker_t *worker, isc__netievent_t *ev0)
* sockets; that's why we need to choose the proper lock.
*/
static void
tcp_listenclose_cb(uv_handle_t *handle)
{
tcp_listenclose_cb(uv_handle_t *handle) {
isc_nmsocket_t *sock = uv_handle_get_data(handle);
isc_mutex_t * lock =
((sock->parent != NULL) ? &sock->parent->lock : &sock->lock);
isc_mutex_t *lock = ((sock->parent != NULL) ? &sock->parent->lock
: &sock->lock);
LOCK(lock);
atomic_store(&sock->closed, true);
@@ -488,8 +468,7 @@ tcp_listenclose_cb(uv_handle_t *handle)
}
static void
readtimeout_cb(uv_timer_t *handle)
{
readtimeout_cb(uv_timer_t *handle) {
isc_nmsocket_t *sock = uv_handle_get_data((uv_handle_t *)handle);
REQUIRE(VALID_NMSOCK(sock));
@@ -515,9 +494,8 @@ readtimeout_cb(uv_timer_t *handle)
}
isc_result_t
isc_nm_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb, void *cbarg)
{
isc_nmsocket_t * sock = NULL;
isc_nm_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb, void *cbarg) {
isc_nmsocket_t *sock = NULL;
isc__netievent_startread_t *ievent = NULL;
REQUIRE(VALID_NMHANDLE(handle));
@@ -543,11 +521,10 @@ 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 *ev0)
{
isc__nm_async_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_nmsocket_t *sock = ievent->sock;
int r;
REQUIRE(worker->id == isc_nm_tid());
if (sock->read_timeout != 0) {
@@ -567,8 +544,7 @@ isc__nm_async_startread(isc__networker_t *worker, isc__netievent_t *ev0)
}
isc_result_t
isc_nm_pauseread(isc_nmsocket_t *sock)
{
isc_nm_pauseread(isc_nmsocket_t *sock) {
isc__netievent_pauseread_t *ievent = NULL;
REQUIRE(VALID_NMSOCK(sock));
@@ -594,10 +570,9 @@ isc_nm_pauseread(isc_nmsocket_t *sock)
}
void
isc__nm_async_pauseread(isc__networker_t *worker, isc__netievent_t *ev0)
{
isc__nm_async_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_nmsocket_t *sock = ievent->sock;
REQUIRE(VALID_NMSOCK(sock));
REQUIRE(worker->id == isc_nm_tid());
@@ -609,8 +584,7 @@ isc__nm_async_pauseread(isc__networker_t *worker, isc__netievent_t *ev0)
}
isc_result_t
isc_nm_resumeread(isc_nmsocket_t *sock)
{
isc_nm_resumeread(isc_nmsocket_t *sock) {
isc__netievent_startread_t *ievent = NULL;
REQUIRE(VALID_NMSOCK(sock));
@@ -638,8 +612,7 @@ isc_nm_resumeread(isc_nmsocket_t *sock)
}
static void
read_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf)
{
read_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) {
isc_nmsocket_t *sock = uv_handle_get_data((uv_handle_t *)stream);
REQUIRE(VALID_NMSOCK(sock));
@@ -689,22 +662,22 @@ read_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf)
}
static isc_result_t
accept_connection(isc_nmsocket_t *ssock)
{
isc_result_t result;
isc_quota_t * quota = NULL;
isc_nmsocket_t * csock = NULL;
isc__networker_t * worker = NULL;
isc_nmhandle_t * handle = NULL;
accept_connection(isc_nmsocket_t *ssock) {
isc_result_t result;
isc_quota_t *quota = NULL;
isc_nmsocket_t *csock = NULL;
isc__networker_t *worker = NULL;
isc_nmhandle_t *handle = NULL;
struct sockaddr_storage ss;
isc_sockaddr_t local;
int r;
isc_sockaddr_t local;
int r;
REQUIRE(VALID_NMSOCK(ssock));
REQUIRE(ssock->tid == isc_nm_tid());
if (!atomic_load_relaxed(&ssock->active) ||
atomic_load_relaxed(&ssock->mgr->closing)) {
atomic_load_relaxed(&ssock->mgr->closing))
{
/* We're closing, bail */
return (ISC_R_CANCELED);
}
@@ -743,8 +716,8 @@ accept_connection(isc_nmsocket_t *ssock)
goto error;
}
result =
isc_sockaddr_fromsockaddr(&csock->peer, (struct sockaddr *)&ss);
result = isc_sockaddr_fromsockaddr(&csock->peer,
(struct sockaddr *)&ss);
if (result != ISC_R_SUCCESS) {
goto error;
}
@@ -785,10 +758,9 @@ error:
}
static void
tcp_connection_cb(uv_stream_t *server, int status)
{
tcp_connection_cb(uv_stream_t *server, int status) {
isc_nmsocket_t *ssock = uv_handle_get_data((uv_handle_t *)server);
isc_result_t result;
isc_result_t result;
UNUSED(status);
@@ -806,11 +778,10 @@ tcp_connection_cb(uv_stream_t *server, int status)
isc_result_t
isc__nm_tcp_send(isc_nmhandle_t *handle, isc_region_t *region, isc_nm_cb_t cb,
void *cbarg)
{
isc_nmsocket_t * sock = handle->sock;
void *cbarg) {
isc_nmsocket_t *sock = handle->sock;
isc__netievent_tcpsend_t *ievent = NULL;
isc__nm_uvreq_t * uvreq = NULL;
isc__nm_uvreq_t *uvreq = NULL;
REQUIRE(sock->type == isc_nm_tcpsocket);
@@ -844,9 +815,8 @@ isc__nm_tcp_send(isc_nmhandle_t *handle, isc_region_t *region, isc_nm_cb_t cb,
}
static void
tcp_send_cb(uv_write_t *req, int status)
{
isc_result_t result = ISC_R_SUCCESS;
tcp_send_cb(uv_write_t *req, int status) {
isc_result_t result = ISC_R_SUCCESS;
isc__nm_uvreq_t *uvreq = (isc__nm_uvreq_t *)req->data;
REQUIRE(VALID_UVREQ(uvreq));
@@ -867,9 +837,8 @@ 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 *ev0)
{
isc_result_t result;
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 *)ev0;
REQUIRE(worker->id == ievent->sock->tid);
@@ -887,8 +856,7 @@ isc__nm_async_tcpsend(isc__networker_t *worker, isc__netievent_t *ev0)
}
static isc_result_t
tcp_send_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req)
{
tcp_send_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
int r;
REQUIRE(sock->tid == isc_nm_tid());
@@ -908,8 +876,7 @@ tcp_send_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req)
}
static void
tcp_close_cb(uv_handle_t *uvhandle)
{
tcp_close_cb(uv_handle_t *uvhandle) {
isc_nmsocket_t *sock = uv_handle_get_data(uvhandle);
REQUIRE(VALID_NMSOCK(sock));
@@ -920,8 +887,7 @@ tcp_close_cb(uv_handle_t *uvhandle)
}
static void
timer_close_cb(uv_handle_t *uvhandle)
{
timer_close_cb(uv_handle_t *uvhandle) {
isc_nmsocket_t *sock = uv_handle_get_data(uvhandle);
REQUIRE(VALID_NMSOCK(sock));
@@ -931,8 +897,7 @@ timer_close_cb(uv_handle_t *uvhandle)
}
static void
tcp_close_direct(isc_nmsocket_t *sock)
{
tcp_close_direct(isc_nmsocket_t *sock) {
REQUIRE(VALID_NMSOCK(sock));
REQUIRE(sock->tid == isc_nm_tid());
REQUIRE(sock->type == isc_nm_tcpsocket);
@@ -944,8 +909,8 @@ tcp_close_direct(isc_nmsocket_t *sock)
if (ssock->overquota) {
isc_result_t result = accept_connection(ssock);
if (result != ISC_R_QUOTA &&
result != ISC_R_SOFTQUOTA) {
if (result != ISC_R_QUOTA && result != ISC_R_SOFTQUOTA)
{
ssock->overquota = false;
}
}
@@ -963,8 +928,7 @@ tcp_close_direct(isc_nmsocket_t *sock)
}
void
isc__nm_tcp_close(isc_nmsocket_t *sock)
{
isc__nm_tcp_close(isc_nmsocket_t *sock) {
REQUIRE(VALID_NMSOCK(sock));
REQUIRE(sock->type == isc_nm_tcpsocket);
@@ -984,8 +948,7 @@ isc__nm_tcp_close(isc_nmsocket_t *sock)
}
void
isc__nm_async_tcpclose(isc__networker_t *worker, isc__netievent_t *ev0)
{
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);
@@ -994,12 +957,12 @@ isc__nm_async_tcpclose(isc__networker_t *worker, isc__netievent_t *ev0)
}
void
isc__nm_tcp_shutdown(isc_nmsocket_t *sock)
{
isc__nm_tcp_shutdown(isc_nmsocket_t *sock) {
REQUIRE(VALID_NMSOCK(sock));
if (sock->type == isc_nm_tcpsocket && sock->tcphandle != NULL &&
sock->rcb.recv != NULL) {
sock->rcb.recv != NULL)
{
sock->rcb.recv(sock->tcphandle, NULL, sock->rcbarg);
}
}