return Socket::connect(conn.peer_addr)
.then([this](SocketRef sock) {
socket = std::move(sock);
- if (state == state_t::closing) {
+ if (state != state_t::connecting) {
+ assert(state == state_t::closing);
return socket->close().then([] {
throw std::system_error(make_error_code(error::protocol_aborted));
});
make_error_code(crimson::net::error::bad_peer_address));
}
if (state != state_t::connecting) {
+ assert(state == state_t::closing);
throw std::system_error(make_error_code(error::protocol_aborted));
}
socket->learn_ephemeral_port_as_connector(caddr.get_port());
return repeat_connect();
});
}).then([this] {
+ if (state != state_t::connecting) {
+ assert(state == state_t::closing);
+ throw std::system_error(make_error_code(error::protocol_aborted));
+ }
execute_open(open_t::connected);
}).handle_exception([this] (std::exception_ptr eptr) {
// TODO: handle fault in the connecting state
return repeat_handle_connect();
});
}).then([this] {
+ if (state != state_t::accepting) {
+ assert(state == state_t::closing);
+ throw std::system_error(make_error_code(error::protocol_aborted));
+ }
messenger.register_conn(
seastar::static_pointer_cast<SocketConnection>(conn.shared_from_this()));
messenger.unaccept_conn(