<div dir="ltr"><div class="gmail_extra">Hi there,</div><div class="gmail_extra"> </div><div class="gmail_extra">I have a situation where subscriptions do not get notified and have tracked it down to a problem with the polled notify processing. Can you advise if this is a bug or correct my understanding of the code.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">I am using kamailio 3.3.3 and have 1 notify process. I have extended the support for the ua-profile event (rfc 6080). When a new subscription arrives it is added to the active_watchers table, the &#39;updated&#39; column is assigned a number in the range 0 - N-1, where N is effectively the total number of polled update tasks that are called in a round-robin fashion, distributed across the notify processes. In this case updated = 7.</div>
<div class="gmail_extra"><br>In subscribe.c:</div><div class="gmail_extra"><div>int update_subscription_notifier(struct sip_msg* msg, subs_t* subs,<span style="white-space:pre-wrap"> </span>int to_tag_gen, int* sent_reply)</div>
<div>{</div><div><span style="white-space:pre-wrap">...</span></div><div><span style="white-space:pre-wrap">        </span>/* Set the notifier/update fields for the subscription */</div><div><span style="white-space:pre-wrap">        </span>subs-&gt;updated = core_hash(&amp;subs-&gt;callid, &amp;subs-&gt;from_tag, 0) %</div>
<div><span style="white-space:pre-wrap">                        </span>(pres_waitn_time * pres_notifier_poll_rate</div><div><span style="white-space:pre-wrap">                                </span>* pres_notifier_processes);</div><div><br></div></div><div class="gmail_extra">
The notify process periodically calls pres_timer_send_notify(), which calculates the round (the update task number) and does the notify update by checking the active_watchers table for entries with updated = round. The update is done twice, first for the event then for event.winfo.</div>
<div class="gmail_extra"><br>In notify.c:</div><div class="gmail_extra"><div>void pres_timer_send_notify(unsigned int ticks, void *param)</div><div>{</div><div><span style="white-space:pre-wrap">        </span>int process_num = *((int *) param);</div>
<div><span style="white-space:pre-wrap">        </span>int round = subset + (pres_waitn_time * pres_notifier_poll_rate</div><div><span style="white-space:pre-wrap">                                </span>* process_num);</div><div><span style="white-space:pre-wrap">        </span>if (process_dialogs(round, 0) &lt; 0)</div>
<div><span style="white-space:pre-wrap">        </span>{</div><div><span style="white-space:pre-wrap">                </span>LM_ERR(&quot;Handling non presence.winfo dialogs\n&quot;);</div><div><span style="white-space:pre-wrap">                </span>return;</div>
<div><span style="white-space:pre-wrap">        </span>}</div><div><span style="white-space:pre-wrap">        </span>if (process_dialogs(round, 1) &lt; 0)</div><div><span style="white-space:pre-wrap">        </span>{</div><div><span style="white-space:pre-wrap">                </span>LM_ERR(&quot;Handling presence.winfo dialogs\n&quot;);</div>
<div><span style="white-space:pre-wrap">                </span>return;</div><div><span style="white-space:pre-wrap">        </span>}</div><div>}</div><div><br></div><div>In this instance process_num = 0, so round = subset. However subset is incremented in process_dialogs() in notify.c:</div>
<div><br></div><div><div><span style="white-space:pre-wrap">        </span>if (++subset &gt; (pres_waitn_time * pres_notifier_poll_rate) -1)</div><div><span style="white-space:pre-wrap">                </span>subset = 0;</div><div><br></div><div>
This means that round is incremented twice between calls to process_dialogs(round, 0), in my case round is always even, hence not detecting the subscription with updated = 7.</div><div><br></div><div>It seems that the subset increment should be done in pres_timer_send_notify() rather than in process_dialogs(). Does that make sense?</div>
<div><br></div><div>Additionally, is there a need for the second call that only handles presence.winfo subscriptions? The code could be simplified by only making one call and processing all subscriptions for the round.<br>
<br></div></div></div><div class="gmail_extra">Cheers</div><div class="gmail_extra">Shane Harrison<br clear="all"><br>-- <br></div><div class="gmail_extra">Imagination NZ Ltd<br>Level 6 </div><div class="gmail_extra">
</div><div class="gmail_extra">92 Queens Drive<br>P0 Box 30449<br>Lower Hutt 5040<br><br>+64 4 5703870 Extn 875<br>+64 21 608919  (mobile)<br></div><div class="gmail_extra">
</div></div>