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.
This commit is contained in:
Robert Mader 2023-02-11 17:38:20 +01:00 committed by George Kiagiadakis
parent 04bf9b013e
commit b8201d2716

View file

@ -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