mod_audio_fork - need of multiple locks/mutexes
Opened this issue · 2 comments
anshumanr commented
Hi @davehorton
We are using mod_audio_fork
module. I was going through the code and could not understand the need to acquire/lock multiple mutexes in func fork_frame()
- mutex part of variable type
struct private_data
is acquired at lws_glue.cpp#L530. - mutex part of class
AudioPipe
and used to access the audio buffers is acquired at lws_glue.cpp#L541
Also, this callback is invoked from func switch_core_session_read_frame()
in switch_core_io.c
inside a lock (bug->read_mutex
). So I could not understand the need to acquire multiple mutexes in fork_frame()
.
Could you please throw some pointers as to what I missed?
Thanks.
davehorton commented
please be patient as you are asking for a detailed investigation and description of the code. If possible I will get to this.
anshumanr commented
I seem to have found the missing piece of my understanding.
struct private_data
is accessed in 2 different threads -fork_frame()
andfork_session_cleanup()
. I believe they can be invoked by FS in 2 different threads.- same for object of type
AudioPipe
. It is accessed infork_frame()
and inAudioPipe::lws_callback()
for caseLWS_CALLBACK_CLIENT_WRITEABLE
. Need to check what that case means.