[LBBS-143] threading: Reduce number of threads in waitjoin state
Several BBS modules launch threads when they start to do something in the background, but don't join those threads until the module unloads.
This leads to a number of threads that simply "linger around" as long as the BBS is running. No memory leak, since they do get cleaned up at shutdown, but this is an unnecessary use of thread resources:
17 3883548 (140481988122304) [0x7fc482ffd6c0] (waitjoin 8:15:01) ami_thread started by thread 3883515 at mod_asterisk_ami.c:748 start_ami_clients()
20 3883564 (140481912587968) [0x7fc47e7f46c0] (waitjoin 8:14:52) names_query started by thread 3883547 at mod_irc_relay.c:910 ensure_names_aware()
21 3883569 (140481937766080) [0x7fc47fff76c0] (waitjoin 8:14:46) names_query started by thread 3883547 at mod_irc_relay.c:910 ensure_names_aware()
22 3883570 (140481929373376) [0x7fc47f7f66c0] (waitjoin 8:14:40) names_query started by thread 3883547 at mod_irc_relay.c:910 ensure_names_aware()
23 3883575 (140481870624448) [0x7fc47bfef6c0] (waitjoin 5:27:35) slack_relay_run started by thread 3883515 at mod_slack.c:1611 start_clients()
24 3883574 (140481879017152) [0x7fc47c7f06c0] (waitjoin 0:00:29) slack_relay_run started by thread 3883515 at mod_slack.c:1611 start_clients()
4 208500 (140388975789824) [0x7faedb084700] (waitjoin 83:16:45) background_task started by thread 208087 at mod_smtp_fetchmail.c:237 load_module()
Not all these operations are conducive to using something like bbs_run_when_started, nor should they necessarily be detached threads. Might be worth having the module reap the threads at some point while running?
Comments
You must be logged in to leave a comment.