[asterisk-dev] [Code Review] 2427: IAX2, prevent network thread starting before all helper threads are ready

Alec Davis reviewboard at asterisk.org
Fri Apr 5 02:13:52 CDT 2013


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/2427/
-----------------------------------------------------------

Review request for Asterisk Developers.


Bugs: ASTERISK-18827
    https://issues.asterisk.org/jira/browse/ASTERISK-18827


Repository: Asterisk


Description
-------

If the first network message was received before iax2_process_thread() was sleeping, the thread would go to sleep, and sleep forever, with deferred frames banking up.

start_network_thread() creates the initial helper threads and the network_thread at the same time (near enough), with no checks that the helper threads were ready before the network thread was created.

Each iax2_process_thread() is required to be at 'ast_cond_wait(&thread->cond, &thread->lock)' before any messages can be accepted.
To achieve this, only start the network_thread after each of the helper threads is ready.

The fix is the same method as find_idle_thread() uses when an iax dynamic thread is created, that then waits for the init_cond to be satisfied.


Diffs
-----

  trunk/channels/chan_iax2.c 376441 

Diff: https://reviewboard.asterisk.org/r/2427/diff/


Testing
-------

Prior to fix, iax show threads had thread 1 never finishing, with actions = 0, which means it never got processed.
...
Thread 10: state=0, update=6, actions=1, func=''
Active Threads:
Thread P1: state=1, update=1365045454, actions=0, func='socket_process'
Dynamic Threads:
10 of 10 threads accounted for with 0 dynamic threads

after fix, works as expected.


Thanks,

Alec Davis

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20130405/2a5f3140/attachment-0001.htm>


More information about the asterisk-dev mailing list