void ProtocolV1::reset_recv_state()
{
- // clean up state internal variables and states
- auth_meta.reset(new AuthConnectionMeta);
- authorizer_more.clear();
- session_security.reset();
+ ldout(cct, 5) << __func__ << dendl;
+
+ // execute in the same thread that uses the `session_security`.
+ // We need to do the warp because holding `write_lock` is not
+ // enough as `write_event()` releases it just before calling
+ // `write_message()`. `submit_to()` here is NOT blocking.
+ connection->center->submit_to(connection->center->get_id(), [this] {
+ ldout(cct, 5) << "reset_recv_state reseting security handlers" << dendl;
+
+ // Possibly unnecessary. See the comment in `deactivate_existing`.
+ std::lock_guard<std::mutex> l(connection->lock);
+ std::lock_guard<std::mutex> wl(connection->write_lock);
+
+ // clean up state internal variables and states
+ auth_meta.reset(new AuthConnectionMeta);
+ authorizer_more.clear();
+ session_security.reset();
+ }, /* nowait = */true);
// clean read and write callbacks
connection->pendingReadLen.reset();