}
using bind_ertr = crimson::errorator<
- crimson::ct_error::address_in_use // The address (range) is already bound
+ crimson::ct_error::address_in_use, // The address (range) is already bound
+ crimson::ct_error::address_not_available
>;
/// bind to the given address
virtual bind_ertr::future<> bind(const entity_addrvec_t& addr) = 0;
if (e.code() == std::errc::address_in_use) {
logger().trace("FixedCPUServerSocket::listen({}): address in use", addr);
return crimson::ct_error::address_in_use::make();
+ } else if (e.code() == std::errc::address_not_available) {
+ logger().trace("FixedCPUServerSocket::listen({}): address not available",
+ addr);
+ return crimson::ct_error::address_not_available::make();
}
logger().error("FixedCPUServerSocket::listen({}): "
"got unexpeted error {}", addr, e);
auto to_bind = addr;
to_bind.set_port(port);
return do_listen(entity_addrvec_t{to_bind}
- ).safe_then([this] () -> seastar::future<std::optional<bool>> {
+ ).safe_then([this] () -> seastar::future<std::optional<std::error_code>> {
logger().info("{} try_bind: done", *this);
- return seastar::make_ready_future<std::optional<bool>>(
- std::make_optional<bool>(true));
+ return seastar::make_ready_future<std::optional<std::error_code>>(
+ std::make_optional<std::error_code>(std::error_code{/* success! */}));
}, listen_ertr::all_same_way([this, max_port, &port]
- (const std::error_code& e) mutable
- -> seastar::future<std::optional<bool>> {
- assert(e == std::errc::address_in_use);
- logger().trace("{} try_bind: {} already used", *this, port);
+ (const std::error_code& e) mutable
+ -> seastar::future<std::optional<std::error_code>> {
+ logger().trace("{} try_bind: {} got error {}", *this, port, e);
if (port == max_port) {
- return seastar::make_ready_future<std::optional<bool>>(
- std::make_optional<bool>(false));
+ return seastar::make_ready_future<std::optional<std::error_code>>(
+ std::make_optional<std::error_code>(e));
}
++port;
- return seastar::make_ready_future<std::optional<bool>>();
+ return seastar::make_ready_future<std::optional<std::error_code>>(
+ std::optional<std::error_code>{std::nullopt});
}));
- }).then([] (bool success) -> bind_ertr::future<> {
- if (success) {
- return bind_ertr::now();
- } else {
+ }).then([] (const std::error_code e) -> bind_ertr::future<> {
+ if (!e) {
+ return bind_ertr::now(); // success!
+ } else if (e == std::errc::address_in_use) {
return crimson::ct_error::address_in_use::make();
+ } else if (e == std::errc::address_not_available) {
+ return crimson::ct_error::address_not_available::make();
}
});
});