replace abandon_server with disconnect_and_reconnect

This commit is contained in:
2026-06-08 15:54:20 -04:00
parent fa7dcdcb0d
commit 53a06281fd

View File

@@ -108,10 +108,11 @@ public:
} }
} }
void abandon_server() { void disconnect_and_reconnect() {
if (channel_) if (channel_)
{ {
set_initial_state_standalone(); eng::string target = channel_->target();
set_initial_state_connect(target);
} }
} }
@@ -138,7 +139,7 @@ public:
// An ack is just a single byte, so there's nothing left to read. // An ack is just a single byte, so there's nothing left to read.
if (unack_.empty()) { if (unack_.empty()) {
// Invalid acknowledgement when theres' nothing in the unack queue. // Invalid acknowledgement when theres' nothing in the unack queue.
abandon_server(); disconnect_and_reconnect();
return; return;
} }
world_to_synchronous(); world_to_synchronous();
@@ -158,7 +159,7 @@ public:
} }
// dbc.dump(...); // dbc.dump(...);
} catch (const StreamException &sexcept) { } catch (const StreamException &sexcept) {
abandon_server(); disconnect_and_reconnect();
return; return;
} }
} }
@@ -179,11 +180,11 @@ public:
} else if (message_type == util::MSG_DIFF) { } else if (message_type == util::MSG_DIFF) {
receive_diff_from_server(&body); receive_diff_from_server(&body);
} else { } else {
abandon_server(); disconnect_and_reconnect();
return false; return false;
} }
if (!body.empty()) { if (!body.empty()) {
abandon_server(); disconnect_and_reconnect();
return false; return false;
} }
return true; return true;
@@ -248,7 +249,7 @@ public:
if (channel_ != nullptr) { if (channel_ != nullptr) {
if (channel_->closed()) { if (channel_->closed()) {
util::dprint("server closed connection: ", channel_->error()); util::dprint("server closed connection: ", channel_->error());
abandon_server(); disconnect_and_reconnect();
} else { } else {
while (true) { while (true) {
if (!receive_message_from_server(channel_->in())) break; if (!receive_message_from_server(channel_->in())) break;