adhearsion/adhearsion — Issue #106: Race condition when dialing multiple destinations
Author: bklang
Created: 2012-02-19 21:07:55+00:00
State: open

At https://github.com/adhearsion/adhearsion/blob/develop/lib/adhearsion/call_controller/dial.rb#L40 there is a lambda to be executed when each of the dialed channels answer. There is a race condition where, if two calls answer at the same instant, both will hangup all the other channels, clobbering each other.

I think the fix would be to make the outer-most `calls` variable (assigned as a result of the map on line 37) a ThreadSafeArray. Then the lock acquired for `calls.each` on line 43 should protect the block, which will also need to be modified to check whether the current call is still alive before proceeding.