From 3a43a0bb34b1c74b19dcdc0401fd6adbc6b94b34 Mon Sep 17 00:00:00 2001 From: Haomai Wang Date: Wed, 13 Jul 2016 01:26:04 +0800 Subject: [PATCH] msg/async/AsyncConnection: fix _conn_prefix racing when stopped When the connection is lossy and enter fault, it will dispatch reset event. If cleanup handler is executed as well as ms_handle_reset call mark_down, it may exists racing for "cs". cleanup handler will reset "cs" but _conn_prefix in mark_down will access "cs". Signed-off-by: Haomai Wang --- src/msg/async/AsyncConnection.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/msg/async/AsyncConnection.cc b/src/msg/async/AsyncConnection.cc index c682dd11585..498cb03ff66 100644 --- a/src/msg/async/AsyncConnection.cc +++ b/src/msg/async/AsyncConnection.cc @@ -28,7 +28,7 @@ #undef dout_prefix #define dout_prefix _conn_prefix(_dout) ostream& AsyncConnection::_conn_prefix(std::ostream *_dout) { - int fd = cs ? cs.fd() : -1; + int fd = (cs && state != STATE_CLOSED) ? cs.fd() : -1; return *_dout << "-- " << async_msgr->get_myinst().addr << " >> " << peer_addr << " conn(" << this << " sd=" << fd << " :" << port << " s=" << get_state_name(state) -- 2.39.5