From: Matthias Kruk Date: Thu, 9 Mar 2023 06:11:33 +0000 (+0900) Subject: include/ipc: Don't send pubsub messages to oneself X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=c469d30e6439bb884286c6431467d4a27c17a132;p=toolbox 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. --- 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")