]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: Monitor::send_reply gracefully handles no connection
authorLoic Dachary <loic@dachary.org>
Wed, 12 Feb 2014 15:48:04 +0000 (16:48 +0100)
committerLoic Dachary <loic@dachary.org>
Thu, 13 Feb 2014 08:45:55 +0000 (09:45 +0100)
If req->get_connection() returns a null pointer, drop the reply instead
of crashing the monitor.

Signed-off-by: Loic Dachary <loic@dachary.org>
src/mon/Monitor.cc

index 35d880c4559c0cf18a41185803d97b419bb35117..a59dcbe211652ecf92abad91f84817ff3bd08c4f 100644 (file)
@@ -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<MonSession*>(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<MonSession*>(connection->get_priv());
   if (!session) {
     dout(2) << "send_reply no session, dropping reply " << *reply
            << " to " << req << " " << *req << dendl;