/*
* Free the resources of the network manager.
- *
- * TODO we need to clean up properly - launch all missing callbacks,
- * destroy all listeners, etc.
*/
static void
nm_destroy(isc_nm_t **mgr0) {
UNLOCK(&worker->lock);
if (worker->finished) {
- /* TODO walk the handles and free them! */
/*
* We need to launch the loop one more time
- * to make sure that worker->async is closed,
- * so that we can close the loop cleanly.
- * We don't care about the callback as in this
- * case we can be certain that uv_run will
- * eat this event.
+ * in UV_RUN_NOWAIT mode to make sure that
+ * worker->async is closed, so that we can
+ * close the loop cleanly. We don't care
+ * about the callback, as in this case we can
+ * be certain that uv_run() will eat the event.
+ *
+ * XXX: We may need to take steps here to ensure
+ * that all netmgr handles are freed.
*/
uv_close((uv_handle_t *)&worker->async, NULL);
uv_run(&worker->loop, UV_RUN_NOWAIT);
if (r == 0) {
/*
- * TODO it should never happen - we don't have
- * any sockets we're listening on?
+ * XXX: uv_run() in UV_RUN_DEFAULT mode returns
+ * zero if there are still active uv_handles.
+ * This shouldn't happen, but if it does, we just
+ * to keep checking until they're done. We nap for a
+ * tenth of a second on each loop so as not to burn
+ * CPU. (We do a conditional wait instead, but it
+ * seems like overkill for this case.)
*/
#ifdef WIN32
_sleep(100);
isc__netievent_storage_t *event =
isc_mem_get(mgr->mctx, sizeof(isc__netievent_storage_t));
- /* XXX: use a memory pool? */
+ /* XXX: Use a memory pool? */
*event = (isc__netievent_storage_t) {
.ni.type = type
};
REQUIRE(isc__nm_in_netthread());
REQUIRE(size <= 65536);
- /* TODO that's for UDP only! */
worker = &sock->mgr->workers[sock->tid];
- INSIST(!worker->udprecvbuf_inuse);
+ INSIST(!worker->recvbuf_inuse);
- buf->base = worker->udprecvbuf;
- worker->udprecvbuf_inuse = true;
+ buf->base = worker->recvbuf;
+ worker->recvbuf_inuse = true;
buf->len = size;
}
}
worker = &sock->mgr->workers[sock->tid];
- REQUIRE(worker->udprecvbuf_inuse);
- REQUIRE(buf->base == worker->udprecvbuf);
+ REQUIRE(worker->recvbuf_inuse);
+ REQUIRE(buf->base == worker->recvbuf);
- worker->udprecvbuf_inuse = false;
+ worker->recvbuf_inuse = false;
}
static isc_nmhandle_t *
handle = isc__nmhandle_get(sock, NULL, NULL);
req->cb.connect(handle, ISC_R_SUCCESS, req->cbarg);
} else {
- /* TODO handle it properly, free sock, translate code */
- req->cb.connect(NULL, ISC_R_FAILURE, req->cbarg);
+ /*
+ * TODO:
+ * Handle the connect error properly and free the socket.
+ */
+ req->cb.connect(NULL, isc__nm_uverr2result(status), req->cbarg);
}
isc__nm_uvreq_put(&req, sock);
sock->rcb.recv(sock->tcphandle, NULL, sock->rcbarg);
/*
- * XXXWPK TODO clean up handles, close the connection,
- * reclaim quota
+ * We don't need to clean up now; the socket will be closed and
+ * resources and quota reclaimed when handle is freed in
+ * isc__nm_tcp_close().
*/
}
if (result == ISC_R_QUOTA || result == ISC_R_SOFTQUOTA) {
ssock->overquota = true;
}
- /* XXXWPK TODO LOG */
+ /* TODO: Log the error. */
}
}
-/*
- * isc__nm_tcp_send sends buf to a peer on a socket.
- */
isc_result_t
isc__nm_tcp_send(isc_nmhandle_t *handle, isc_region_t *region,
isc_nm_cb_t cb, void *cbarg)
isc_quota_detach(&sock->quota);
if (ssock->overquota) {
- /* XXXWPK TODO we should loop here */
isc_result_t result = accept_connection(ssock);
if (result != ISC_R_QUOTA && result != ISC_R_SOFTQUOTA)
{