From 5ea156a09a8a575e7b6c247dc5fbfec0121b60d9 Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Wed, 12 Feb 2014 16:48:04 +0100 Subject: [PATCH] mon: Monitor::send_reply gracefully handles no connection If req->get_connection() returns a null pointer, drop the reply instead of crashing the monitor. Signed-off-by: Loic Dachary --- src/mon/Monitor.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 35d880c4559c0..a59dcbe211652 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -2526,7 +2526,14 @@ void Monitor::try_send_message(Message *m, const entity_inst_t& to) void Monitor::send_reply(PaxosServiceMessage *req, Message *reply) { - MonSession *session = static_cast(req->get_connection()->get_priv()); + ConnectionRef connection = req->get_connection(); + if (!connection) { + dout(2) << "send_reply no connection, dropping reply " << *reply + << " to " << req << " " << *req << dendl; + reply->put(); + return; + } + MonSession *session = static_cast(connection->get_priv()); if (!session) { dout(2) << "send_reply no session, dropping reply " << *reply << " to " << req << " " << *req << dendl; -- 2.39.5