From 02e1393c9ff284f0e07c63c487fa37dba385cd50 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Fri, 1 Sep 2023 16:20:07 +0300 Subject: [PATCH] policy-node: destroy node only after sending an error to the client if the node is destroyed before, pw_stream shuts down and doesn't relay the error to the application --- src/scripts/policy-node.lua | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/scripts/policy-node.lua b/src/scripts/policy-node.lua index 25d71362..ed06fa25 100644 --- a/src/scripts/policy-node.lua +++ b/src/scripts/policy-node.lua @@ -770,10 +770,7 @@ function handleLinkable (si) Log.info (si, "... target not found, reconnect:" .. tostring(reconnect)) local node = si:get_associated_proxy ("node") - if not reconnect then - Log.info (si, "... destroy node") - node:request_destroy() - elseif si_flags[si.id].was_handled then + if reconnect and si_flags[si.id].was_handled then Log.info (si, "... waiting reconnect") return end @@ -783,9 +780,20 @@ function handleLinkable (si) local client = clients_om:lookup { Constraint { "bound-id", "=", client_id, type = "gobject" } } - if client then - client:send_error(node["bound-id"], -2, "no node available") + local message + if reconnect then + message = "no target node available" + else + message = "target not found" end + if client then + client:send_error(node["bound-id"], -2, message) + end + end + + if not reconnect then + Log.info (si, "... destroy node") + node:request_destroy() end else createLink (si, si_target, can_passthrough, exclusive)