Ensure atomicity/synchronisation in isc_nmsocket_shutdown() for multi-layer transports (HTTP/2 and Generic TLS code).
The current implementation of isc_nmsocket_shutdown()
for HTTP/2 and generic TLS transport does not explicitly guarantee that clean shutdown is performed and no new associated connections will be accepted after the call of isc_nmsocket_shutdown()
has been completed, and its associated data is safe to destroy. That could lead to potential issues on a BIND shutdown as well as unit tests for "multilayer" transports.
To fix that, we can do the following:
- Mark the listening socket as being shutting down so that the associated connections being accepted at the moment might notice that we are wrapping up and handle the situation accordingly;
- Broadcast a "stop" message on all worker threads and wait for them to be processed. Then, the underlying listening socket can be safely shot down too. Something very similar is being done in other transports implemented directly on top of libUV - but there is a separate "child" socket object associated with any worker. For "multilayer" transports, we can do simpler than that, as there is no direct need to maintain a per-worker object.
Edited by Artem Boldariev