From 6339c5d43974f4b495f15d199e01a141e74235f5 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 23 Dec 2012 09:19:05 -0800 Subject: [PATCH] msgr: don't queue message on closed pipe If we have a con that refs a pipe but it is closed, don't use it. If the ref is still there, it is only because we are racing with fault() and it is about to (or just was) be detached. Either way, Signed-off-by: Sage Weil --- src/msg/Pipe.h | 5 ----- src/msg/SimpleMessenger.cc | 14 +++++++++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/msg/Pipe.h b/src/msg/Pipe.h index 1bcc8263f4a69..28b4864c33ca4 100644 --- a/src/msg/Pipe.h +++ b/src/msg/Pipe.h @@ -243,11 +243,6 @@ class DispatchQueue; } void stop(); - void send(Message *m) { - pipe_lock.Lock(); - _send(m); - pipe_lock.Unlock(); - } void _send(Message *m) { out_q[m->get_priority()].push_back(m); cond.Signal(); diff --git a/src/msg/SimpleMessenger.cc b/src/msg/SimpleMessenger.cc index a6e2f98450591..3d2eb79b37656 100644 --- a/src/msg/SimpleMessenger.cc +++ b/src/msg/SimpleMessenger.cc @@ -397,10 +397,18 @@ void SimpleMessenger::submit_message(Message *m, Connection *con, return; } if (pipe) { - ldout(cct,20) << "submit_message " << *m << " remote, " << dest_addr << ", have pipe." << dendl; - pipe->send(m); + pipe->pipe_lock.Lock(); + if (pipe->state != Pipe::STATE_CLOSED) { + ldout(cct,20) << "submit_message " << *m << " remote, " << dest_addr << ", have pipe." << dendl; + pipe->_send(m); + pipe->pipe_lock.Unlock(); + pipe->put(); + return; + } + pipe->pipe_lock.Unlock(); pipe->put(); - return; + ldout(cct,20) << "submit_message " << *m << " remote, " << dest_addr + << ", had pipe " << pipe << ", but it closed." << dendl; } } -- 2.39.5