Cleaning up lpxclient and lpxserver in preparation for redirect implementation

This commit is contained in:
2026-06-01 22:49:25 -04:00
parent 1b0d96934f
commit bfaf161d30
6 changed files with 45 additions and 18 deletions

View File

@@ -91,6 +91,7 @@ public:
bool handle_invocation(UniqueClient &client) {
StreamBuffer *sb = client->channel_->in();
if (sb->empty()) return false;
int64_t tr_before = sb->total_reads();
Invocation inv;
try {
@@ -107,18 +108,29 @@ public:
delete_client(client);
return false;
}
// If the user sent an invalid kind, log them out.
if (!Invocation::is_valid_network_kind(inv.kind())) {
delete_client(client);
return false;
}
// Acknowledge the invocation.
client->channel_->out()->write_uint8(util::MSG_ACK);
client->channel_->out()->write_uint32(0);
// Process the invocation.
// Execute the invocation with the sync model.
client->sync_->invoke(inv);
client->async_diff_ = true;
// Process the invocation in the master model.
//
// An invoke with the wrong actor_id is quietly a noop. This is
// to make leeway for clients who have recently been redirected, and
// who may not know their new actor_id yet.
//
if (inv.actor() == client->actor_id_) {
world_->invoke(inv);
client->sync_->invoke(inv);
client->async_diff_ = true;
}
return true;
}
@@ -150,7 +162,9 @@ public:
case AccessKind::CHANNEL_PRINTS: {
// If there's nothing new in the printbuffer, this is very fast.
if (print_channeler_.channel(world_->get_printbuffer(actor_id_), retpk)) {
world_->invoke(print_channeler_.invocation(actor_id_));
// TODO: Don't necessarily need to do this on every line of output.
// Can send this every 30 seconds or so.
delayed_invocations_.emplace_back(print_channeler_.invocation(actor_id_));
}
set_have_prints(false);
break;