diff --git a/src/runtime2/scheduler.rs b/src/runtime2/scheduler.rs index 8e33bedf26f4d0290cca2be1eeea18447ada1cb5..43574bcd840dadf478a2bd9ecd610dc7987b1709 100644 --- a/src/runtime2/scheduler.rs +++ b/src/runtime2/scheduler.rs @@ -316,14 +316,18 @@ impl Scheduler { let port = scheduled.ctx.ports.remove(port_index); new_connector.ctx.ports.push(port.clone()); - // Notify the peer that the port has changed - let reroute_message = scheduled.router.prepare_reroute( - port.self_id, port.peer_id, scheduled.ctx.id, - port.peer_connector, new_connector.ctx.id - ); - - self.debug_conn(connector_id, &format!("Sending message [newcon]\n --- {:?}", reroute_message)); - self.runtime.send_message(port.peer_connector, Message::Control(reroute_message)); + // Notify the peer that the port has changed, but only + // if the port wasn't already closed (otherwise the peer + // is gone). + if port.state == PortState::Open { + let reroute_message = scheduled.router.prepare_reroute( + port.self_id, port.peer_id, scheduled.ctx.id, + port.peer_connector, new_connector.ctx.id + ); + + self.debug_conn(connector_id, &format!("Sending message [newcon]\n --- {:?}", reroute_message)); + self.runtime.send_message(port.peer_connector, Message::Control(reroute_message)); + } } // Schedule new connector to run