From fb3cd0c2a8f27a1c8d601a478fd896cc0b609011 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 30 May 2013 22:52:21 -0700 Subject: [PATCH] mon: discard messages from disconnected clients If the client is not connected, discard the message. They will reconnect and resend anyway, so there is no point in processing it twice (now and later). Signed-off-by: Sage Weil Reviewed-by: Greg Farnum --- src/mon/Monitor.cc | 2 +- src/mon/PaxosService.cc | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 89048a17f9b..72fd3777a8c 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -2889,7 +2889,7 @@ void Monitor::handle_forward(MForward *m) dout(0) << "forward from entity with insufficient caps! " << session->caps << dendl; } else { - Connection *c = new Connection(NULL); + Connection *c = new Connection(NULL); // msgr must be null; see PaxosService::dispatch() MonSession *s = new MonSession(m->msg->get_source_inst(), c); c->set_priv(s); c->set_peer_addr(m->client.addr); diff --git a/src/mon/PaxosService.cc b/src/mon/PaxosService.cc index e360215b94f..8840fcecc35 100644 --- a/src/mon/PaxosService.cc +++ b/src/mon/PaxosService.cc @@ -44,6 +44,18 @@ bool PaxosService::dispatch(PaxosServiceMessage *m) return true; } + // make sure the client is still connected. note that a proxied + // connection will be disconnected with a null message; don't drop + // those. also ignore loopback (e.g., log) messages. + if (!m->get_connection()->is_connected() && + m->get_connection() != mon->messenger->get_loopback_connection() && + m->get_connection()->get_messenger() != NULL) { + dout(10) << " discarding message from disconnected client " + << m->get_source_inst() << " " << *m << dendl; + m->put(); + return true; + } + // make sure our map is readable and up to date if (!is_readable(m->version)) { dout(10) << " waiting for paxos -> readable (v" << m->version << ")" << dendl; -- 2.47.3