using crimson::common::local_conf;
-class Connection {
+class Connection : public seastar::enable_shared_from_this<Connection> {
public:
Connection(const AuthRegistry& auth_registry,
crimson::net::ConnectionRef conn,
return conn->send(m).then([this] {
logger().info("waiting");
return auth_reply.get_shared_future();
- }).then([this] (Ref<MAuthReply> m) {
+ }).then([this, life_extender=shared_from_this()] (Ref<MAuthReply> m) {
if (!m) {
ceph_assert(closed);
logger().info("do_auth_single: connection closed");
seastar::future<Connection::auth_result_t>
Connection::do_auth(Connection::request_t what) {
- return seastar::repeat_until_value([this, what]() {
+ return seastar::repeat_until_value(
+ [this, life_extender=shared_from_this(), what]() {
return do_auth_single(what);
});
}
logger().info("{} to mon.{}", __func__, rank);
if (active_con) {
active_con->close();
- active_con.reset();
+ active_con = nullptr;
ceph_assert(pending_conns.empty());
} else {
for (auto& pending_con : pending_conns) {
logger().info("connecting to mon.{}", rank);
auto conn = msgr.connect(peer, CEPH_ENTITY_TYPE_MON);
auto& mc = pending_conns.emplace_back(
- std::make_unique<Connection>(auth_registry, conn, &keyring));
+ seastar::make_shared<Connection>(auth_registry, conn, &keyring));
assert(conn->get_peer_addr().is_msgr2());
return mc->authenticate_v2().then([peer, this](auto result) {
if (result == Connection::auth_result_t::success) {
ceph_assert(!active_con && !pending_conns.empty());
active_con = std::move(*found);
- found->reset();
+ *found = nullptr;
for (auto& conn : pending_conns) {
if (conn) {
conn->close();
#include <seastar/core/future.hh>
#include <seastar/core/gate.hh>
#include <seastar/core/lowres_clock.hh>
+#include <seastar/core/shared_ptr.hh>
#include <seastar/core/timer.hh>
#include "auth/AuthRegistry.h"
const uint32_t want_keys;
MonMap monmap;
- std::unique_ptr<Connection> active_con;
- std::vector<std::unique_ptr<Connection>> pending_conns;
+ seastar::shared_ptr<Connection> active_con;
+ std::vector<seastar::shared_ptr<Connection>> pending_conns;
seastar::timer<seastar::lowres_clock> timer;
crimson::net::Messenger& msgr;