[Freeswitch-users] esl_recv_event() from two threads on the same handle

Shlomi Agiv shlomi.agiv at cell-buddy.com
Tue Aug 5 12:13:59 MSD 2014

I'm using the C ESL events api.
I have one threads that continuously checks for updates
using esl_recv_event()
I have another thread that sometimes needs to inject commands, that
uses esl_send_recv() on the same handle.
It looks like on occasion, both get stuck and stop receiving events.

Is it possible for two threads to access the handle? maybe I should open
two connections to freeswitch esl? or use esl_send_recv_timed()?

stack trace:
#0  0xb6f3f974 in __lll_lock_wait () from
#1  0xb6f39858 in pthread_mutex_lock () from
#2  0x000f2f2c in esl_mutex_lock (mutex=<optimized out>) at
#3  0x000efb70 in esl_recv_event (handle=0x11b67c, check_q=0,
save_event=0xb6c47da4) at src/esl.c:1262
#4  0x0001ebbc in EslHandler::initThread (this=0x11b670) at
#5  0x0001ec88 in EslHandler::entryPoint (eslHandler=0x11b670) at
#6  0xb6f36b04 in start_thread () from
#7  0xb6d25a2c in ?? () from /lib/arm-linux-gnueabi/libc.so.6
#8  0xb6d25a2c in ?? () from /lib/arm-linux-gnueabi/libc.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) thread 1
[Switching to thread 1 (Thread 0xb6c4a000 (LWP 3020))]
#0  0xb6d17c04 in poll () from /lib/arm-linux-gnueabi/libc.so.6
(gdb) info stack
#0  0xb6d17c04 in poll () from /lib/arm-linux-gnueabi/libc.so.6
#1  0x000ef92c in esl_wait_sock (sock=<optimized out>, ms=<optimized out>,
flags=<optimized out>) at src/esl.c:929
#2  0x000ef988 in handle_recv (handle=0x11b67c, data=0x11b91c,
datalen=65535) at src/esl.c:1230
#3  0x000efc84 in esl_recv_event (handle=0x11b67c, check_q=<optimized out>,
save_event=0x12c120) at src/esl.c:1323
#4  0x000f0ba4 in esl_send_recv_timed (ms=0, cmd=<optimized out>,
handle=0x11b67c) at src/esl.c:1554
#5  esl_send_recv_timed (handle=0x11b67c, cmd=<optimized out>, ms=0) at
#6  0x0001f2e0 in EslHandler::sendAtCommand (this=0x11b670, atCmd=...) at
#7  0x0001f86c in EslHandler::getImsiFromSim (this=0x11b670) at
#8  0x0001450c in FsControl::checkMessages (this=0x11b2a0) at
#9  0x000124cc in FsControl::handleEslCustomEvent (this=0x11b2a0,
mapEventReceived=...) at fsControl.cpp:376
#10 0x0000f334 in FsControl::handleEslEvent (this=0x11b2a0,
mapEventReceived=...) at fsControl.cpp:226
#11 0x0000e7a8 in FsControl::OnWaitHandle (this=0x11b2a0, whp=0x13aea8,
data=...) at fsControl.cpp:140
#12 0x000d230c in os::Schedualed::OnEvent (this=0x11b2a0, event=0x13aea8,
data=...) at cpp/os.cpp:1578
#13 0x000cd1d0 in os::Schedualer::mainloop (this=0x11b348,
exitOnNoneManaged=false) at cpp/os.cpp:446
#14 0x000161e0 in main (argc=3, argv=0xbea16904) at fsControl.cpp:603
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20140805/5eb83a34/attachment.html 

Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list