/*% Child sockets for multi-socket setups */
isc_nmsocket_t *children;
- int nchildren;
+ uint_fast32_t nchildren;
isc_nmiface_t *iface;
isc_nmhandle_t *statichandle;
isc_nmhandle_t *outerhandle;
* We shouldn't be here unless there are no active handles,
* so we can clean up and free the children.
*/
- for (int i = 0; i < sock->nchildren; i++) {
+ for (size_t i = 0; i < sock->nchildren; i++) {
if (!atomic_load(&sock->children[i].destroying)) {
nmsocket_cleanup(&sock->children[i],
false FLARG_PASS);
active_handles = atomic_load(&sock->ah);
if (sock->children != NULL) {
- for (int i = 0; i < sock->nchildren; i++) {
+ for (size_t i = 0; i < sock->nchildren; i++) {
LOCK(&sock->children[i].lock);
active_handles += atomic_load(&sock->children[i].ah);
UNLOCK(&sock->children[i].lock);
* so they can be cleaned up too.
*/
if (sock->children != NULL) {
- for (int i = 0; i < sock->nchildren; i++) {
+ for (size_t i = 0; i < sock->nchildren; i++) {
atomic_store(&sock->children[i].active, false);
}
}
memset(sock->children, 0, children_size);
sock->result = ISC_R_DEFAULT;
- sock->tid = isc_random_uniform(mgr->nworkers);
+ sock->tid = isc_random_uniform(sock->nchildren);
sock->fd = -1;
#if !HAVE_SO_REUSEPORT_LB && !defined(WIN32)
fd = isc__nm_tcp_lb_socket(sa_family);
#endif
- for (size_t i = 0; i < mgr->nworkers; i++) {
+ for (size_t i = 0; i < sock->nchildren; i++) {
isc__netievent_tcplisten_t *ievent = NULL;
isc_nmsocket_t *csock = &sock->children[i];
#endif
LOCK(&sock->lock);
- while (sock->rchildren != mgr->nworkers) {
+ while (sock->rchildren != sock->nchildren) {
WAIT(&sock->cond, &sock->lock);
}
result = sock->result;
INSIST(result != ISC_R_DEFAULT);
if (result == ISC_R_SUCCESS) {
- REQUIRE(sock->rchildren == mgr->nworkers);
+ REQUIRE(sock->rchildren == sock->nchildren);
*sockp = sock;
} else {
atomic_store(&sock->active, false);
REQUIRE(VALID_NMSOCK(sock));
REQUIRE(sock->type == isc_nm_tcplistener);
- for (int i = 0; i < sock->nchildren; i++) {
+ for (size_t i = 0; i < sock->nchildren; i++) {
isc__netievent_tcpstop_t *ievent = NULL;
isc_nmsocket_t *csock = &sock->children[i];
REQUIRE(VALID_NMSOCK(csock));
memset(sock->children, 0, children_size);
sock->result = ISC_R_DEFAULT;
- sock->tid = isc_random_uniform(mgr->nworkers);
+ sock->tid = isc_random_uniform(sock->nchildren);
sock->fd = -1;
#if !HAVE_SO_REUSEPORT_LB && !defined(WIN32)
fd = isc__nm_tcpdns_lb_socket(sa_family);
#endif
- for (size_t i = 0; i < mgr->nworkers; i++) {
+ for (size_t i = 0; i < sock->nchildren; i++) {
isc__netievent_tcpdnslisten_t *ievent = NULL;
isc_nmsocket_t *csock = &sock->children[i];
#endif
LOCK(&sock->lock);
- while (sock->rchildren != mgr->nworkers) {
+ while (sock->rchildren != sock->nchildren) {
WAIT(&sock->cond, &sock->lock);
}
result = sock->result;
INSIST(result != ISC_R_DEFAULT);
if (result == ISC_R_SUCCESS) {
- REQUIRE(sock->rchildren == mgr->nworkers);
+ REQUIRE(sock->rchildren == sock->nchildren);
*sockp = sock;
} else {
atomic_store(&sock->active, false);
REQUIRE(VALID_NMSOCK(sock));
REQUIRE(sock->type == isc_nm_tcpdnslistener);
- for (int i = 0; i < sock->nchildren; i++) {
+ for (size_t i = 0; i < sock->nchildren; i++) {
isc__netievent_tcpdnsstop_t *ievent = NULL;
isc_nmsocket_t *csock = &sock->children[i];
REQUIRE(VALID_NMSOCK(csock));
sock->recv_cbarg = cbarg;
sock->extrahandlesize = extrahandlesize;
sock->result = ISC_R_DEFAULT;
- sock->tid = isc_random_uniform(mgr->nworkers);
+ sock->tid = isc_random_uniform(sock->nchildren);
sock->fd = -1;
#if !HAVE_SO_REUSEPORT_LB && !defined(WIN32)
fd = isc__nm_udp_lb_socket(sa_family);
#endif
- for (size_t i = 0; i < mgr->nworkers; i++) {
+ for (size_t i = 0; i < sock->nchildren; i++) {
isc__netievent_udplisten_t *ievent = NULL;
isc_nmsocket_t *csock = &sock->children[i];
#endif
LOCK(&sock->lock);
- while (sock->rchildren != mgr->nworkers) {
+ while (sock->rchildren != sock->nchildren) {
WAIT(&sock->cond, &sock->lock);
}
result = sock->result;
INSIST(result != ISC_R_DEFAULT);
if (result == ISC_R_SUCCESS) {
- REQUIRE(sock->rchildren == mgr->nworkers);
+ REQUIRE(sock->rchildren == sock->nchildren);
*sockp = sock;
} else {
atomic_store(&sock->active, false);
REQUIRE(VALID_NMSOCK(sock));
REQUIRE(sock->type == isc_nm_udplistener);
- for (int i = 0; i < sock->nchildren; i++) {
+ for (size_t i = 0; i < sock->nchildren; i++) {
isc__netievent_udpstop_t *ievent = NULL;
isc_nmsocket_t *csock = &sock->children[i];
REQUIRE(VALID_NMSOCK(csock));
isc_uv_udp_freebind(uv_udp_t *handle, const struct sockaddr *addr,
unsigned int flags) {
int r;
- int fd;
+ uv_os_sock_t fd;
r = uv_fileno((const uv_handle_t *)handle, (uv_os_fd_t *)&fd);
if (r < 0) {
return (r);
}
+#if defined(WIN32)
+ REQUIRE(fd != INVALID_SOCKET);
+#endif
+
r = uv_udp_bind(handle, addr, flags);
if (r == UV_EADDRNOTAVAIL &&
isc__nm_socket_freebind(fd, addr->sa_family) == ISC_R_SUCCESS)
isc_uv_tcp_freebind(uv_tcp_t *handle, const struct sockaddr *addr,
unsigned int flags) {
int r;
- int fd;
+ uv_os_sock_t fd;
r = uv_fileno((const uv_handle_t *)handle, (uv_os_fd_t *)&fd);
if (r < 0) {