From: Ondřej Surý Date: Mon, 5 Oct 2020 10:25:19 +0000 (+0200) Subject: Use uv_os_sock_t instead of uv_os_fd_t for sockets X-Git-Tag: v9.17.6~14^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=acb6ad9e3c1b1c873c0cd535262cbe7730b5b750;p=thirdparty%2Fbind9.git Use uv_os_sock_t instead of uv_os_fd_t for sockets On POSIX based systems both uv_os_sock_t and uv_os_fd_t are both typedef to int. That's not true on Windows, where uv_os_sock_t is SOCKET and uv_os_fd_t is HANDLE and they differ in level of indirection. --- diff --git a/lib/isc/netmgr/netmgr-int.h b/lib/isc/netmgr/netmgr-int.h index 72c76a5afd1..1ea281e251f 100644 --- a/lib/isc/netmgr/netmgr-int.h +++ b/lib/isc/netmgr/netmgr-int.h @@ -834,25 +834,25 @@ isc__nm_decstats(isc_nm_t *mgr, isc_statscounter_t counterid); */ isc_result_t -isc__nm_socket_freebind(uv_os_fd_t fd, sa_family_t sa_family); +isc__nm_socket_freebind(uv_os_sock_t fd, sa_family_t sa_family); /*%< * Set the IP_FREEBIND (or equivalent) socket option on the uv_handle */ isc_result_t -isc__nm_socket_reuseport(uv_os_fd_t fd); +isc__nm_socket_reuseport(uv_os_sock_t fd); /*%< * Set the SO_REUSEPORT (or equivalent) socket option on the fd */ isc_result_t -isc__nm_socket_incoming_cpu(uv_os_fd_t fd); +isc__nm_socket_incoming_cpu(uv_os_sock_t fd); /*%< * Set the SO_INCOMING_CPU socket option on the fd if available */ isc_result_t -isc__nm_socket_dontfrag(uv_os_fd_t fd, sa_family_t sa_family); +isc__nm_socket_dontfrag(uv_os_sock_t fd, sa_family_t sa_family); /*%< * Set the SO_IP_DONTFRAG (or equivalent) socket option of the fd if available */ diff --git a/lib/isc/netmgr/netmgr.c b/lib/isc/netmgr/netmgr.c index 02ad0b2c549..7567ee30ffc 100644 --- a/lib/isc/netmgr/netmgr.c +++ b/lib/isc/netmgr/netmgr.c @@ -1584,7 +1584,7 @@ isc__nm_decstats(isc_nm_t *mgr, isc_statscounter_t counterid) { setsockopt(socket, level, name, &(int){ 1 }, sizeof(int)) isc_result_t -isc__nm_socket_freebind(uv_os_fd_t fd, sa_family_t sa_family) { +isc__nm_socket_freebind(uv_os_sock_t fd, sa_family_t sa_family) { /* * Set the IP_FREEBIND (or equivalent option) on the uv_handle. */ @@ -1625,7 +1625,7 @@ isc__nm_socket_freebind(uv_os_fd_t fd, sa_family_t sa_family) { } isc_result_t -isc__nm_socket_reuseport(uv_os_fd_t fd) { +isc__nm_socket_reuseport(uv_os_sock_t fd) { /* * This is SO_REUSE**** hell: * @@ -1668,7 +1668,7 @@ isc__nm_socket_reuseport(uv_os_fd_t fd) { } isc_result_t -isc__nm_socket_incoming_cpu(uv_os_fd_t fd) { +isc__nm_socket_incoming_cpu(uv_os_sock_t fd) { #ifdef SO_INCOMING_CPU if (setsockopt_on(fd, SOL_SOCKET, SO_INCOMING_CPU) == -1) { return (ISC_R_FAILURE); @@ -1682,7 +1682,7 @@ isc__nm_socket_incoming_cpu(uv_os_fd_t fd) { } isc_result_t -isc__nm_socket_dontfrag(uv_os_fd_t fd, sa_family_t sa_family) { +isc__nm_socket_dontfrag(uv_os_sock_t fd, sa_family_t sa_family) { /* * Set the Don't Fragment flag on IP packets */ diff --git a/lib/isc/netmgr/tcp.c b/lib/isc/netmgr/tcp.c index 25400837025..5f731ddfee8 100644 --- a/lib/isc/netmgr/tcp.c +++ b/lib/isc/netmgr/tcp.c @@ -319,7 +319,7 @@ isc__nm_async_tcplisten(isc__networker_t *worker, isc__netievent_t *ev0) { struct sockaddr_storage sname; int r, flags = 0, snamelen = sizeof(sname); sa_family_t sa_family; - uv_os_fd_t fd; + uv_os_sock_t fd; REQUIRE(isc__nm_in_netthread()); REQUIRE(sock->type == isc_nm_tcplistener); @@ -344,7 +344,7 @@ isc__nm_async_tcplisten(isc__networker_t *worker, isc__netievent_t *ev0) { r = uv_tcp_bind(&sock->uv_handle.tcp, &sock->iface->addr.type.sa, flags); if (r == UV_EADDRNOTAVAIL && - uv_fileno(&sock->uv_handle.handle, &fd) == 0 && + uv_fileno(&sock->uv_handle.handle, (uv_os_fd_t *)&fd) == 0 && isc__nm_socket_freebind(fd, sa_family) == ISC_R_SUCCESS) { /*