clean up netmgr reference counting
When the netmgr was first written, we chose to use a reference counting method for netmgr handle objects that was fragile. isc_nmhandle_ref()
and isc_nmhandle_unref()
increase or decrease the reference count for a handle like pushing and popping a stack, but they do not change the value of a handle pointer the way attach and detach functions do. This produced nicely readable code when the netmgr stack was relatively stable, but each time a new subsystem was converted to use netmgr we would encounter bugs in which handles were either detached too soon or left attached until shutdown, and these bugs are time-consuming to find and fix.
We are now switching to a conventional attach/detach model for handles. A caller can maintain multiple handle pointers for use when multiple asynchronous operations may be in flight; for example, ns_client
objects could contain members reqhandle
(attached while waiting for a query, update, or notify request callback), fetchhandle
(attached while waiting for a recursive fetch), sendhandle
(attached while waiting for a send to complete), and udpatehandle
(attached while waiting for an update forwarding task event).