Make the nmhandle attach/detach transparent
Currently, the netmgr callbacks need to manually attach/detach to the isc_nmhandle_t
which makes the usage very error prone (it's fairly easy to forgot some weird path).
The code needs to be refactored, so the attach/detach is internal to the netmgr and not visible to the outside, e.g. instead of doing:
isc_nm_udpconnect(..., connect_cb, ...);
void
connect_cb(handle, ...) {
isc_nmhandle_attach(handle, &read_handle);
isc_nm_read(read_handle, read_cb, ...);
isc_nmhandle_attach(handle, &send_handle);
isc_nm_send(send_handle, send_cb, ...);
isc_nmhandle_detach(&handle);
}
void
read_cb(handle, ...) {
/* process data */
isc_nmhandle_detach(&handle);
}
void
send_cb(handle, ...) {
/* process */
isc_nmhandle_detach(&handle);
}
we should just do:
isc_nm_udpconnect(..., connect_cb, ...);
void
connect_cb(handle, ...) {
isc_nm_read(handle, read_cb, ...);
isc_nm_send(handle, send_cb, ...);
}
void
read_cb(handle, ...) {
/* process */
}
void
send_cb(handle, ...) {
/* process */
}
Basically, the isc_nm_read()
, isc_nm_send()
and others needs to attach to the handle itself, and detach after calling the use supplied callback. It's probably going to be a little bit more complicated than that, but it should be fairly straightforward to fix all the paths in the code.