mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 23:04:52 +09:00
Fix bad command and request sending in subspace_storage
Ignore inventory updates and orders while the instance is not in the running state to avoid sending commands before the server has started up, and also ignore orders if the connection to the master server isn't isn't online to avoid piling up requests in the buffer during session resume attempts.
This commit is contained in:
1 parent
715ab343bf
commit
ddd1bde1b4
1 file changed
+13
-5
@@ -10,13 +10,12 @@ class InstancePlugin extends libPlugin.BaseInstancePlugin {
|
||||
}
|
||||
|
||||
async init() {
|
||||
this.stopping = false;
|
||||
this.pendingTasks = new Set();
|
||||
this.instance.server.on("ipc-subspace_storage:output", (output) => {
|
||||
this.provideItems(output).catch(err => this.unexpectedError(err));
|
||||
});
|
||||
this.instance.server.on("ipc-subspace_storage:orders", (orders) => {
|
||||
if (this.stopping) {
|
||||
if (this.instance.status !== "running" || !this.slave.connected) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -41,7 +40,6 @@ class InstancePlugin extends libPlugin.BaseInstancePlugin {
|
||||
|
||||
async onStop() {
|
||||
clearInterval(this.pingId);
|
||||
this.stopping = true;
|
||||
await Promise.all(this.pendingTasks);
|
||||
}
|
||||
|
||||
@@ -51,6 +49,16 @@ class InstancePlugin extends libPlugin.BaseInstancePlugin {
|
||||
|
||||
// provide items --------------------------------------------------------------
|
||||
async provideItems(items) {
|
||||
if (!this.slave.connector.hasSession) {
|
||||
// For now the items are voided if the master connection is
|
||||
// down, which is no different from the previous behaviour.
|
||||
if (this.instance.config.get("subspace_storage.log_item_transfers")) {
|
||||
this.logger.verbose("Voided the following items:");
|
||||
this.logger.verbose(JSON.stringify(items));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
this.info.messages.place.send(this.instance, {
|
||||
items,
|
||||
instance_id: this.instance.id,
|
||||
@@ -84,8 +92,8 @@ class InstancePlugin extends libPlugin.BaseInstancePlugin {
|
||||
}
|
||||
|
||||
// combinator signals ---------------------------------------------------------
|
||||
async updateStorageEventHandler(message, event) {
|
||||
if (this.stopping) {
|
||||
async updateStorageEventHandler(message) {
|
||||
if (this.instance.status !== "running") {
|
||||
return;
|
||||
}
|
||||
let items = message.data.items;
|
||||
|
||||
Reference in new issue
Block a user