From 0a49db8e6fa141a36ca964e68017d02b81ae7a3c Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 13 Aug 2014 17:52:25 -0700 Subject: [PATCH] msg/PipeConnection: make methods behave on 'anon' connection The monitor does a create_anon_connection() to create a pseudo Connection object for forwarded messages. If we try to call mark_down or similar on one of these we should silently ignore the operation, not crash. If we try to send a message, still crash (explicitly assert); the caller should probably know better. Fixes: #9062 Signed-off-by: Sage Weil --- src/msg/PipeConnection.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/msg/PipeConnection.cc b/src/msg/PipeConnection.cc index e03ddd0a0f9e..695b2266e489 100644 --- a/src/msg/PipeConnection.cc +++ b/src/msg/PipeConnection.cc @@ -69,6 +69,7 @@ void PipeConnection::reset_pipe(Pipe *p) int PipeConnection::send_message(Message *m) { + assert(msgr); return static_cast(msgr)->send_message(m, this); } @@ -79,10 +80,12 @@ void PipeConnection::send_keepalive() void PipeConnection::mark_down() { - static_cast(msgr)->mark_down(this); + if (msgr) + static_cast(msgr)->mark_down(this); } void PipeConnection::mark_disposable() { - static_cast(msgr)->mark_disposable(this); + if (msgr) + static_cast(msgr)->mark_disposable(this); } -- 2.47.3