]> git.corax.cc Git - toolbox/commitdiff
include/ipc: Don't send pubsub messages to oneself
authorMatthias Kruk <m@m10k.eu>
Thu, 9 Mar 2023 06:11:33 +0000 (15:11 +0900)
committerMatthias Kruk <m@m10k.eu>
Thu, 9 Mar 2023 06:25:52 +0000 (15:25 +0900)
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

index a980d72b9dae94924dffa22a62d49ec7dfc5cf7a..b6b6c9d2d7d46b28c51a33eff2573eca8feed12d 100644 (file)
@@ -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")