<p>sungtae kim has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/11201">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Fixed duplicated subscription adding<br><br>Currently, when the stasis adding the subscription, it doesn't<br>check the existed subscriptions.<br><br>It could be possible to causing the duplicated subscription.<br><br>ASTERISK-28357<br><br>Change-Id: I00bd627e4cc21aba0535d2695460a04f06f6e699<br>---<br>M main/stasis.c<br>1 file changed, 7 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/01/11201/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/stasis.c b/main/stasis.c</span><br><span>index 7dd3893..9a0d4eb 100644</span><br><span>--- a/main/stasis.c</span><br><span>+++ b/main/stasis.c</span><br><span>@@ -315,6 +315,8 @@</span><br><span> /*! The number of buckets to use for subscription statistics */</span><br><span> #define SUBSCRIPTION_STATISTICS_BUCKETS 57</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+#define TOPIC_SUBSCRIPTION_CMP(a, b) (!strcmp(a->uniqueid, b->uniqueid))</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /*! Container which stores statistics for topics */</span><br><span> static struct ao2_container *topic_statistics;</span><br><span> </span><br><span>@@ -1026,6 +1028,7 @@</span><br><span> static int topic_add_subscription(struct stasis_topic *topic, struct stasis_subscription *sub)</span><br><span> {</span><br><span>      size_t idx;</span><br><span style="color: hsl(120, 100%, 40%);">+   struct stasis_subscription *tmp_subscription;</span><br><span> </span><br><span>    ao2_lock(topic);</span><br><span>     /* The reference from the topic to the subscription is shared with</span><br><span>@@ -1034,7 +1037,10 @@</span><br><span>   *</span><br><span>    * If we bumped the refcount here, the owner would have to unsubscribe</span><br><span>        * and cleanup, which is a bit awkward. */</span><br><span style="color: hsl(0, 100%, 40%);">-      AST_VECTOR_APPEND(&topic->subscribers, sub);</span><br><span style="color: hsl(120, 100%, 40%);">+   tmp_subscription = AST_VECTOR_GET_CMP(&topic->subscribers, sub, TOPIC_SUBSCRIPTION_CMP);</span><br><span style="color: hsl(120, 100%, 40%);">+       if (!tmp_subscription) {</span><br><span style="color: hsl(120, 100%, 40%);">+              AST_VECTOR_APPEND(&topic->subscribers, sub);</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span> </span><br><span>        for (idx = 0; idx < AST_VECTOR_SIZE(&topic->upstream_topics); ++idx) {</span><br><span>             topic_add_subscription(</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/11201">change 11201</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/11201"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I00bd627e4cc21aba0535d2695460a04f06f6e699 </div>
<div style="display:none"> Gerrit-Change-Number: 11201 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: sungtae kim <pchero21@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>