chore: phase 1 cleanup — proper shutdown, flow resource cleanup, test fix

- node_runner: track all readers/writers in flow_resources vector,
  release them via mxlReleaseFlowWriter/mxlReleaseFlowReader before
  destroying the MXL instance (fixes 'leaked flow writer' warning)
- node_runner: remove_writer/remove_reader commands now also release
  the MXL flow resources, not just reset the node's optional<>
- engine: call process_manager.stop_all(graph) on shutdown to kill
  child node processes (prevents orphaned passthrough processes)
- graph: add get_node_mut() for process_manager to update node state
- process_manager: implement stop_all(Graph&) that SIGTERMs all
  running node processes
- passthrough: reduce logging to first-grain and realign-once only
- tests: update flow format assertion to match NMOS
  (urn:x-nmos:format:video instead of video/v210)
This commit is contained in:
Johanness
2026-05-26 23:04:16 +03:00
parent 5b48d86c6e
commit 4b50f49172
8 changed files with 68 additions and 9 deletions
+5
View File
@@ -51,6 +51,11 @@ const GraphNode* Graph::get_node(const NodeId& node_id) const {
return it != nodes_.end() ? &it->second : nullptr;
}
GraphNode* Graph::get_node_mut(const NodeId& node_id) {
auto it = nodes_.find(node_id);
return it != nodes_.end() ? &it->second : nullptr;
}
std::vector<GraphNode> Graph::get_nodes() const {
std::vector<GraphNode> result;
for (const auto& [_, node] : nodes_) {
+16
View File
@@ -90,6 +90,22 @@ bool ProcessManager::stop_node(GraphNode& node) {
void ProcessManager::stop_all() {
}
void ProcessManager::stop_all(Graph& graph) {
for (auto& node : graph.get_nodes()) {
if (node.state == NodeState::Running && node.pid > 0) {
kill(node.pid, SIGTERM);
int status = 0;
waitpid(node.pid, &status, 0);
auto* mut_node = graph.get_node_mut(node.id);
if (mut_node) {
mut_node->pid = 0;
mut_node->state = NodeState::Stopped;
}
spdlog::info("ProcessManager: stopped node '{}' pid={}", node.id, node.pid);
}
}
}
bool ProcessManager::is_running(const NodeId& node_id) const {
return false;
}