From c469d30e6439bb884286c6431467d4a27c17a132 Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Thu, 9 Mar 2023 15:11:33 +0900 Subject: [PATCH] include/ipc: Don't send pubsub messages to oneself When publishing a pubsub message, ipc_endpoint_publish() sends the message to all subscribers, including the endpoint that is used to send the message, if it is subscribed to that topic. However, an endpoint should not receive its own messages. This commit modifies ipc_endpoint_publish() so that it skips over the sending endpoint if it is among the recipients. --- include/ipc.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/ipc.sh b/include/ipc.sh index a980d72..b6b6c9d 100644 --- a/include/ipc.sh +++ b/include/ipc.sh @@ -686,6 +686,9 @@ ipc_endpoint_publish() { fi while read -r subscriber; do + if [[ "$subscriber" == "$endpoint" ]]; then + continue + fi ipc_endpoint_send "$endpoint" "$subscriber" "$message" "$topic" done < <(_ipc_endpoint_topic_get_subscribers "$topic") -- 2.47.3