From: Sage Weil Date: Thu, 14 Aug 2014 00:52:25 +0000 (-0700) Subject: msg/PipeConnection: make methods behave on 'anon' connection X-Git-Tag: v0.85~44^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0a49db8e6fa141a36ca964e68017d02b81ae7a3c;p=ceph.git 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 --- 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); }