From: Kefu Chai Date: Tue, 22 Nov 2022 04:06:33 +0000 (+0800) Subject: crimson/net: print shared_ptr using fmt::ptr() X-Git-Tag: v18.1.0~846^2~2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=42dc970392e8c49fde46aae66ce8ef81ff00d49c;p=ceph-ci.git crimson/net: print shared_ptr using fmt::ptr() in {fmt} v9, only `void*` pointers can be printed directly. when it comes to typed pointer or smart pointers, we need to print them using `fmt::ptr()`. in this change, an overload is added so we can print `seastar::shared_ptr<>` via `fmt::ptr()` as well, just like how we print `std::shared_ptr<>`. Signed-off-by: Kefu Chai --- diff --git a/src/crimson/net/ProtocolV2.cc b/src/crimson/net/ProtocolV2.cc index 2b41e868f00..54d42f6ef3e 100644 --- a/src/crimson/net/ProtocolV2.cc +++ b/src/crimson/net/ProtocolV2.cc @@ -100,6 +100,13 @@ inline uint64_t generate_client_cookie() { } // namespace anonymous +namespace fmt { + +template auto ptr(const ::seastar::shared_ptr& p) -> const void* { + return p.get(); +} + +} namespace crimson::net { #ifdef UNIT_TESTS_BUILT @@ -1095,7 +1102,7 @@ ProtocolV2::handle_existing_connection(SocketConnectionRef existing_conn) " found existing {}(state={}, gs={}, pgs={}, cs={}, cc={}, sc={})", conn, global_seq, peer_global_seq, connect_seq, client_cookie, server_cookie, - existing_conn, get_state_name(existing_proto->state), + fmt::ptr(existing_conn), get_state_name(existing_proto->state), existing_proto->global_seq, existing_proto->peer_global_seq, existing_proto->connect_seq, @@ -1104,7 +1111,7 @@ ProtocolV2::handle_existing_connection(SocketConnectionRef existing_conn) if (!validate_peer_name(existing_conn->get_peer_name())) { logger().error("{} server_connect: my peer_name doesn't match" - " the existing connection {}, abort", conn, existing_conn); + " the existing connection {}, abort", conn, fmt::ptr(existing_conn)); abort_in_fault(); } @@ -1360,7 +1367,7 @@ ProtocolV2::server_reconnect() " found existing {}(state={}, gs={}, pgs={}, cs={}, cc={}, sc={})", conn, global_seq, peer_global_seq, reconnect.connect_seq(), reconnect.client_cookie(), reconnect.server_cookie(), - existing_conn, + fmt::ptr(existing_conn), get_state_name(existing_proto->state), existing_proto->global_seq, existing_proto->peer_global_seq, @@ -1370,7 +1377,7 @@ ProtocolV2::server_reconnect() if (!validate_peer_name(existing_conn->get_peer_name())) { logger().error("{} server_reconnect: my peer_name doesn't match" - " the existing connection {}, abort", conn, existing_conn); + " the existing connection {}, abort", conn, fmt::ptr(existing_conn)); abort_in_fault(); }