isc__netievent_udplisten_t *ievent =
(isc__netievent_udplisten_t *) ev0;
isc_nmsocket_t *sock = ievent->sock;
+ int r, flags = 0;
REQUIRE(sock->type == isc_nm_udpsocket);
REQUIRE(sock->iface != NULL);
isc_nmsocket_attach(sock,
(isc_nmsocket_t **)&sock->uv_handle.udp.data);
- uv_udp_open(&sock->uv_handle.udp, sock->fd);
- int flags = 0;
+ r = uv_udp_open(&sock->uv_handle.udp, sock->fd);
+ if (r == 0) {
+ isc__nm_incstats(sock->mgr, sock->statsindex[STATID_OPEN]);
+ } else {
+ isc__nm_incstats(sock->mgr,
+ sock->statsindex[STATID_OPENFAIL]);
+ }
+
if (sock->iface->addr.type.sa.sa_family == AF_INET6) {
flags = UV_UDP_IPV6ONLY;
}
- uv_udp_bind(&sock->uv_handle.udp,
- &sock->parent->iface->addr.type.sa, flags);
+
+ r = uv_udp_bind(&sock->uv_handle.udp,
+ &sock->parent->iface->addr.type.sa, flags);
+ if (r < 0) {
+ isc__nm_incstats(sock->mgr,
+ sock->statsindex[STATID_BINDFAIL]);
+ }
+
uv_recv_buffer_size(&sock->uv_handle.handle,
&(int){16 * 1024 * 1024});
uv_send_buffer_size(&sock->uv_handle.handle,
&(int){16 * 1024 * 1024});
- uv_udp_recv_start(&sock->uv_handle.udp, isc__nm_alloc_cb,
- udp_recv_cb);
+ uv_udp_recv_start(&sock->uv_handle.udp, isc__nm_alloc_cb, udp_recv_cb);
}
static void
uv_udp_recv_stop(&sock->uv_handle.udp);
uv_close((uv_handle_t *) &sock->uv_handle.udp, udp_close_cb);
+ isc__nm_incstats(sock->mgr, sock->statsindex[STATID_CLOSE]);
+
LOCK(&sock->parent->lock);
atomic_fetch_sub(&sock->parent->rchildren, 1);
UNLOCK(&sock->parent->lock);
}
/*
- * udp_recv_cb handles incoming UDP packet from uv.
- * The buffer here is reused for a series of packets,
- * so we need to allocate a new one. This new one can
- * be reused to send the response then.
+ * udp_recv_cb handles incoming UDP packet from uv. The buffer here is
+ * reused for a series of packets, so we need to allocate a new one. This
+ * new one can be reused to send the response then.
*/
static void
udp_recv_cb(uv_udp_t *handle, ssize_t nrecv, const uv_buf_t *buf,
if (status < 0) {
result = isc__nm_uverr2result(status);
+ isc__nm_incstats(uvreq->sock->mgr,
+ uvreq->sock->statsindex[STATID_SENDFAIL]);
}
uvreq->cb.send(uvreq->handle, result, uvreq->cbarg);
&sock->uv_handle.udp, &req->uvbuf, 1,
&peer->type.sa, udp_send_cb);
if (rv < 0) {
+ isc__nm_incstats(req->sock->mgr,
+ req->sock->statsindex[STATID_SENDFAIL]);
return (isc__nm_uverr2result(rv));
}