Hello,<br><br>The processing for presence.winfo and other events do require separate calls. This is because the processing of the dialogs in the first call can affect the processing of the dialogs in the second.<br><br>If all event types were handled in one call some processing would not occur until the next handling of the round - five seconds later.<br><br>It may well be the case that there is a bug in the loop as you described, but my statement from before still holds that the notifier stuff will never work properly in 3.3 due to DB limitations - even if you fix the bug you&#39;ve found you will need to use the version in bit master to cope with any real load.<br><br>I suppose the DB limitations may not be an issue on a single server (non-resilient) presence configuration, but in that case you should use the default (non-notifier) setup for presence anyway.<br><br>Regards,<br><br>Peter<br><br>Shane Harrison &lt;shane.harrison@paragon.co.nz&gt; wrote:<br><br><div dir="ltr"><div class="gmail_quote">Hi all,<br><div dir="ltr">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>

<br></div><div>I am using kamailio 3.3.3 and have 1 notify process. I have enhanced the support for the ua-profile event (rfc 6080) , although I don&#39;t believe I have made any changes that directly impact the problem I am seeing. </div>
<div> </div><div>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><br></div><div><div>In subscribe.c:</div><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>
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><br></div><div><div>In notify.c:</div><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(). Is this correct?</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.</div>

</div></div></div>
</div><div> </div><div>Kind regards</div><div>Shane Harrison<br><br clear="all"><br>-- <br></div><div>Imagination NZ Ltd<br>Level 6 </div>
<div>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>