Summary:ASTERISK-16617: ao2_t_callback of dialog_needdestroy is called every loop of do_monitor
Reporter:Stefan Schmidt (schmidts)Labels:
Date Opened:2010-08-25 10:05:10Date Closed:2010-09-21 15:27:05
Versions:Frequency of
Environment:Attachments:( 0) chan_sip.c.patch3
Description:the ao2_t_callback is fired in every loop of do_monitor which cause asterisk to slow down if there are many open dialogs. I wrote a patch to count up to 10 seconds and then launch the ao2_t_callback only once. the time is only count between the start and end of ast_io_wait cause there is a polling (waiting) done.
Comments:By: Stefan Schmidt (schmidts) 2010-08-25 12:43:49

as i have seen the code of 1.8 the ao2 callback could handle multiple dialogs which may be faster than in 1.6 where this doesnt work.

the second time struct end could be deleteted and also this row of the patch:
just replace in this row the end with ast_tvnow();
so it would be

to compare the speed of this patch. with more than 500 sip dialogs active, the ao2 callback tooks up to 2000 usec. the ast_tvdiff_ms function just needs around 20 to 30 usec.

By: Stefan Schmidt (schmidts) 2010-08-26 09:13:22

i think i found a problem of this solution by myself. if dialog_needdestroy is not called when asterisk is shut down, the memory will not become free, so there is a leak with this. is there a way to call the ao2_t_callback if the thread should be closed? i dont know much about this pthreadtestcancel function.

By: Stefan Schmidt (schmidts) 2010-09-08 18:25:03

i am now writing a patch to link all dialogs which are marked as needdestroy into an own container and just iterate through this container.
speeds up the things a little bit and clean up the dialogs faster than this patch above.
i only got one problem, the rtp_checktimeout function is also in this dialogneeddestroy callback to check if there are dialogs with rtpchecktimeout set. maybe i could use another container for this ;)

By: Stefan Schmidt (schmidts) 2010-09-15 02:39:38

atleast this is related to https://reviewboard.asterisk.org/r/917/

By: Digium Subversion (svnbot) 2010-09-21 15:27:05

Repository: asterisk
Revision: 288063

U   trunk/channels/chan_sip.c

r288063 | schmitds | 2010-09-21 15:27:04 -0500 (Tue, 21 Sep 2010) | 12 lines

Instead of iterate through all dialogs, add two separte container for needdestroy and rtptimeout

adding two dialog container, one for dialogs which need destroy, another for rtptimeout checks.
both container will be checked on every loop of do_monitor instead of iterate through all dialogs.

(closes issue ASTERISK-16617)
Reported by: schmidts
Tested by: schmidts

Review: https://reviewboard.asterisk.org/r/917/