Previously, the isccc_ccmsg_invalidate() was called from conn_free() and
this could lead to netmgr calling control_recvmessage() after we
detached the reading controlconnection_t reference, but it wouldn't be
the last reference because controlconnection_t is also attached/detached
when sending response or running command asynchronously.
Instead, move the isccc_ccmsg_invalidate() call to control_recvmessage()
error handling path to make sure that control_recvmessage() won't be
ever called again from the netmgr.
isccc_time_t exp;
uint32_t nonce;
- if (conn->shuttingdown) {
- return;
- }
+ INSIST(!conn->shuttingdown);
/* Is the server shutting down? */
if (listener->controls->shuttingdown) {
return;
cleanup:
+ /* Make sure no read callbacks are called again */
+ isccc_ccmsg_invalidate(&conn->ccmsg);
+
conn->shuttingdown = true;
REQUIRE(isc_tid() == 0);
}
#endif /* ifdef ENABLE_AFL */
- isccc_ccmsg_invalidate(&conn->ccmsg);
-
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_CONTROL, ISC_LOG_DEBUG(3),
"freeing control connection");