2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

Move netmgr/uv-compat.h to <isc/uv.h>

As we are going to use libuv outside of the netmgr, we need the shims to
be readily available for the rest of the codebase.

Move the "netmgr/uv-compat.h" to <isc/uv.h> and netmgr/uv-compat.c to
uv.c, and as a rule of thumb, the users of libuv should include
<isc/uv.h> instead of <uv.h> directly.

Additionally, merge netmgr/uverr2result.c into uv.c and rename the
single function from isc__nm_uverr2result() to isc_uverr2result().
This commit is contained in:
Ondřej Surý
2022-04-27 17:41:47 +02:00
parent 24c3879675
commit b43812692d
24 changed files with 168 additions and 206 deletions

View File

@@ -13,7 +13,6 @@
#include <libgen.h>
#include <unistd.h>
#include <uv.h>
#include <isc/atomic.h>
#include <isc/barrier.h>
@@ -33,9 +32,9 @@
#include <isc/stdtime.h>
#include <isc/thread.h>
#include <isc/util.h>
#include <isc/uv.h>
#include "netmgr-int.h"
#include "uv-compat.h"
static atomic_uint_fast32_t last_tcpquota_log = 0;
@@ -175,7 +174,7 @@ tcp_connect_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
atomic_store(&sock->connected, true);
done:
result = isc__nm_uverr2result(r);
result = isc_uverr2result(r);
LOCK(&sock->lock);
sock->result = result;
SIGNAL(&sock->cond);
@@ -262,7 +261,7 @@ tcp_connect_cb(uv_connect_t *uvreq, int status) {
result = ISC_R_TIMEDOUT;
goto error;
} else if (status != 0) {
result = isc__nm_uverr2result(status);
result = isc_uverr2result(status);
goto error;
}
@@ -270,7 +269,7 @@ tcp_connect_cb(uv_connect_t *uvreq, int status) {
r = uv_tcp_getpeername(&sock->uv_handle.tcp, (struct sockaddr *)&ss,
&(int){ sizeof(ss) });
if (r != 0) {
result = isc__nm_uverr2result(r);
result = isc_uverr2result(r);
goto error;
}
@@ -586,7 +585,7 @@ isc__nm_async_tcplisten(isc__networker_t *worker, isc__netievent_t *ev0) {
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
ISC_LOGMODULE_NETMGR, ISC_LOG_ERROR,
"uv_listen failed: %s",
isc_result_totext(isc__nm_uverr2result(r)));
isc_result_totext(isc_uverr2result(r)));
isc__nm_incstats(sock, STATID_BINDFAIL);
goto done;
}
@@ -594,7 +593,7 @@ isc__nm_async_tcplisten(isc__networker_t *worker, isc__netievent_t *ev0) {
atomic_store(&sock->listening, true);
done:
result = isc__nm_uverr2result(r);
result = isc_uverr2result(r);
if (result != ISC_R_SUCCESS) {
sock->pquota = NULL;
}
@@ -616,7 +615,7 @@ tcp_connection_cb(uv_stream_t *server, int status) {
isc_quota_t *quota = NULL;
if (status != 0) {
result = isc__nm_uverr2result(status);
result = isc_uverr2result(status);
goto done;
}
@@ -853,7 +852,7 @@ isc__nm_tcp_read_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) {
isc__nm_incstats(sock, STATID_RECVFAIL);
}
isc__nm_tcp_failed_read_cb(sock, isc__nm_uverr2result(nread));
isc__nm_tcp_failed_read_cb(sock, isc_uverr2result(nread));
goto free;
}
@@ -970,14 +969,14 @@ accept_connection(isc_nmsocket_t *ssock, isc_quota_t *quota) {
r = uv_accept(&ssock->uv_handle.stream, &csock->uv_handle.stream);
if (r != 0) {
result = isc__nm_uverr2result(r);
result = isc_uverr2result(r);
goto failure;
}
r = uv_tcp_getpeername(&csock->uv_handle.tcp, (struct sockaddr *)&ss,
&(int){ sizeof(ss) });
if (r != 0) {
result = isc__nm_uverr2result(r);
result = isc_uverr2result(r);
goto failure;
}
@@ -990,7 +989,7 @@ accept_connection(isc_nmsocket_t *ssock, isc_quota_t *quota) {
r = uv_tcp_getsockname(&csock->uv_handle.tcp, (struct sockaddr *)&ss,
&(int){ sizeof(ss) });
if (r != 0) {
result = isc__nm_uverr2result(r);
result = isc_uverr2result(r);
goto failure;
}
@@ -1090,8 +1089,7 @@ tcp_send_cb(uv_write_t *req, int status) {
if (status < 0) {
isc__nm_incstats(sock, STATID_SENDFAIL);
isc__nm_failed_send_cb(sock, uvreq,
isc__nm_uverr2result(status));
isc__nm_failed_send_cb(sock, uvreq, isc_uverr2result(status));
return;
}
@@ -1135,7 +1133,7 @@ tcp_send_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
r = uv_write(&req->uv_req.write, &sock->uv_handle.stream, &req->uvbuf,
1, tcp_send_cb);
if (r < 0) {
return (isc__nm_uverr2result(r));
return (isc_uverr2result(r));
}
isc_nm_timer_create(req->handle, isc__nmsocket_writetimeout_cb, req,