#include "crimson/net/chained_dispatchers.h"
#include "Messenger.h"
+#include "Socket.h"
#include "SocketConnection.h"
namespace crimson::net {
bool started = false;
listen_ertr::future<> do_listen(const entity_addrvec_t& addr);
+ /// try to bind to the first unused port of given address
+ bind_ertr::future<> try_bind(const entity_addrvec_t& addr,
+ uint32_t min_port, uint32_t max_port);
+
public:
SocketMessenger(const entity_name_t& myname,
// behavior should be symmetric when called from any shard.
bind_ertr::future<> bind(const entity_addrvec_t& addr) override;
- bind_ertr::future<> try_bind(const entity_addrvec_t& addr,
- uint32_t min_port, uint32_t max_port) override;
-
seastar::future<> start(const dispatchers_t& dispatchers) override;
ConnectionRef connect(const entity_addr_t& peer_addr,
Heartbeat::start_messenger(crimson::net::Messenger& msgr,
const entity_addrvec_t& addrs)
{
- return msgr.try_bind(addrs,
- local_conf()->ms_bind_port_min,
- local_conf()->ms_bind_port_max)
- .safe_then([this, &msgr]() mutable {
+ return msgr.bind(addrs).safe_then([this, &msgr]() mutable {
return msgr.start({this});
}, crimson::net::Messenger::bind_ertr::all_same_way(
[] (const std::error_code& e) {
- logger().error("heartbeat messenger try_bind(): address range is unavailable.");
+ logger().error("heartbeat messenger bind(): address range is unavailable.");
ceph_abort();
}));
}
crimson::net::dispatchers_t dispatchers{this, monc.get(), mgrc.get()};
return seastar::when_all_succeed(
- cluster_msgr->try_bind(pick_addresses(CEPH_PICK_ADDRESS_CLUSTER),
- local_conf()->ms_bind_port_min,
- local_conf()->ms_bind_port_max)
+ cluster_msgr->bind(pick_addresses(CEPH_PICK_ADDRESS_CLUSTER))
.safe_then([this, dispatchers]() mutable {
return cluster_msgr->start(dispatchers);
}, crimson::net::Messenger::bind_ertr::all_same_way(
[] (const std::error_code& e) {
- logger().error("cluster messenger try_bind(): address range is unavailable.");
+ logger().error("cluster messenger bind(): address range is unavailable.");
ceph_abort();
})),
- public_msgr->try_bind(pick_addresses(CEPH_PICK_ADDRESS_PUBLIC),
- local_conf()->ms_bind_port_min,
- local_conf()->ms_bind_port_max)
+ public_msgr->bind(pick_addresses(CEPH_PICK_ADDRESS_PUBLIC))
.safe_then([this, dispatchers]() mutable {
return public_msgr->start(dispatchers);
}, crimson::net::Messenger::bind_ertr::all_same_way(
[] (const std::error_code& e) {
- logger().error("public messenger try_bind(): address range is unavailable.");
+ logger().error("public messenger bind(): address range is unavailable.");
ceph_abort();
})));
}).then_unpack([this] {