From b8201d2716ceca34511cefafb653d0cc53a366dc Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Sat, 11 Feb 2023 17:38:20 +0100 Subject: [PATCH] policy-node: handle WpSiStandardLink link-error signal It gets emitted e.g. on format negotiation errors. Send `-EPIPE` errors to the respective clients to let them close the connection. --- src/scripts/policy-node.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/scripts/policy-node.lua b/src/scripts/policy-node.lua index 38e8171e..eb540884 100644 --- a/src/scripts/policy-node.lua +++ b/src/scripts/policy-node.lua @@ -98,6 +98,26 @@ function createLink (si, si_target, passthrough, exclusive) return end + si_link:connect("link-error", function (_, error_msg) + Log.info (si_link, "got link-error signal: " .. error_msg) + + local n1 = si:get_associated_proxy ("node") + local n2 = si_target:get_associated_proxy ("node") + + for _, node in ipairs ({n1, n2}) do + local client_id = node.properties["client.id"] + if client_id then + local client = clients_om:lookup { + Constraint { "bound-id", "=", client_id, type = "gobject" } + } + if client then + Log.info (node, "sending client error") + client:send_error(node["bound-id"], -32, error_msg) + end + end + end + end) + -- register si_flags[si_id].peer_id = si_target.id si_flags[si_id].failed_peer_id = si_target.id