Ben,

The way it works is:

There is a mutex protected queue in which commands are enqueued and
dequeued. The mutexes are just to protects the main stack thread which
serves the queue and the application thread which enqueues the new commands
into the queue. The gCmdMutex is the one which does this. What's happening
in your case is, that the make call command is enqueued and the gCmdMutex is
released by the application thread. The command mutex is acquired by the
stack thread to process the MakeCall command and while doing so, still
acquiring gCmdMuex, the stack thread calls the startReceiveChannel callback.
Now if you have released your application mutex in MakeCall by this time,
this should go through and there shouldn't be a deadlock.

You are right about error conditions and I will fix them right away. Also,
can you give more details about what you are trying to achieve so that I
will go through the mutex code keeping your requirements in mind, while I am
at it.

Regards,
Vishal




----- Original Message ----- 
From: "Ben Greear" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, September 26, 2005 9:44 AM
Subject: Re: [ooh323c-devel] callback locking?


> Ben Greear wrote:
> > Hello!
> >
> > I added locking to my ooh323 client and I notice a deadlock:
> >
> > My code grabs a lock and calls oo to start a call.
> >
> > I also acquire the same lock when handling the callback for
> > onStartReceiveChannel.  It appears that I deadlock here.
> >
> > I thought I read somewhere that the commands sent to ooh323c
> > go onto a queue so that this problem would not occur?
>
> So, after fighting with GDB for some time, I have found the deadlock.
>
> For whatever reason, the second thread (my thread) cannot
> get the gCmdMutex lock.  Just looking at the nearby code,
> I notice none of the error cases unlock the mutex before
> returning, so that is instant deadlock waiting to happen :(
>
> If these simple thread locking errors exist, there is no
> telling what other more sinister problems exist.
>
> So, I believe I will just remove all the threads from ooh323c and
> my program.  (I have already cleaned out the rtp stack, so just the main
> loop of ooh323c to go.)
>
> Thread 2 (Thread -1208136784 (LWP 27528)):
> #0  0xffffe410 in __kernel_vsyscall ()
> #1  0x48c86eee in __lll_mutex_lock_wait () from /lib/tls/libpthread.so.0
> #2  0x48c83df4 in _L_mutex_lock_29 () from /lib/tls/libpthread.so.0
> #3  0x081d9940 in __s_cell_cnt ()
> #4  0xb7fd4798 in ?? ()
> #5  0x00000106 in ?? ()
> #6  0xb7fd4bb0 in ?? ()
> #7  0xb7fd4970 in ?? ()
> #8  0xb7fd47b8 in ?? ()
> #9  0x080944d4 in ooHangCall (callToken=0x81dab94 "\002",
reason=3086829936)
>      at ooStackCmds.c:225
> #10 0x080944d4 in ooHangCall (callToken=0x81e669c "ooh323c_2",
>      reason=OO_REASON_LOCAL_CLEARED) at ooStackCmds.c:225
> #11 0x08057e88 in HVoipEndp::doTick (this=0x81e2ec0, input_fds=0xb7fd49f0,
>      output_fds=0xb7fd4970, exc_fds=0xb7fd48f0, now=1127674726632) at
LFVoipEndp.cc:382
> #12 0x0804f628 in LFVoipThread::tick (this=0xbffff420,
input_fds=0xb7fd49f0,
>      output_fds=0xb7fd4970, exc_fds=0xb7fd48f0, now=1127674726632) at
LFVoipHelper.cc:247
> #13 0x0804ed98 in LFVoipThread::run (this=0xbffff420) at
LFVoipHelper.cc:127
> #14 0x0805426f in osEpHandleCommand (dummy=0xbffff420) at lfphone.cc:317
> #15 0x48c8198c in start_thread () from /lib/tls/libpthread.so.0
> #16 0x48a837da in clone () from /lib/tls/libc.so.6
>
> Thread 1 (Thread -1208029056 (LWP 27526)):
> #0  0xffffe410 in __kernel_vsyscall ()
> #1  0x48c86eee in __lll_mutex_lock_wait () from /lib/tls/libpthread.so.0
> #2  0x48c83e09 in _L_mutex_lock_156 () from /lib/tls/libpthread.so.0
> #3  0x081b14a0 in typeinfo name for LogStream ()
> #4  0xbfffeef8 in ?? ()
> #5  0x081e6900 in ?? ()
> #6  0x081d8024 in gProtocolID ()
> #7  0x08212344 in ?? ()
> #8  0xbfffeef8 in ?? ()
> #9  0x08053401 in LFLockable::acquireLock (this=0x81e6900,
> ---Type <return> to continue, or q <return> to quit---
>      file_=0x804e168
"U\211\uffff\203\uffff\b\203\uffff\bh\231\uffff\032\b\uffffu\b\uffff\030\uff
ff\uffff\uffff\203\uffff\020\203\uffff\f\uffffu\b\uffff<\uffff\uffff\uffff\2
03\uffff\020\213E\b\uffff\uffffU\211\uffffS\203\uffff\004\203\uffff\004\213E
\b\213\030\203\uffff\f\uffffu\f\203\uffff\004\uffffu\f\uffff\236\003",
line_=-1073746136) at StackLock.cc:26
> #10 0x08053401 in LFLockable::acquireLock (this=0x81e6900,
>      file_=0x81b18a5 "LFVoipEndp.cc", line_=1174) at StackLock.cc:26
> #11 0x0805349d in StackLock (this=0xbfffef40, l=0x81e6900,
>      file=0x81b18a5 "LFVoipEndp.cc", line=1174) at StackLock.cc:42
> #12 0x0805c07d in HVoipEndp::onStartReceiveChannel (this=0x81e2ec0,
call=0x81df338,
>      pChannel=0x81df688) at LFVoipEndp.cc:1174
> #13 0x08053ed5 in osEpStartReceiveChannel (call=0x81df338,
pChannel=0x81df688)
>      at lfphone.cc:178
> #14 0x080856e5 in ooBuildFastStartOLC (call=0x81df338, olc=0x8213a10,
epCap=0x81e19b0,
>      pctxt=0x81da888, dir=1) at ooh245.c:3319
> #15 0x0808abf9 in ooH323MakeCall_helper (call=0x81df338) at ooq931.c:2162
> #16 0x0808a195 in ooH323CallAdmitted (call=0x81df338) at ooq931.c:1864
> #17 0x0808a0c0 in ooH323MakeCall (dest=0x81e1a68 "172.22.22.2:5060",
>      callToken=0x81e1a88 "ooh323c_2", opts=0x0) at ooq931.c:1832
> #18 0x080946e2 in ooProcStackCmds () at ooStackCmds.c:288
> #19 0x0807c9e5 in ooMonitorChannels () at oochannels.c:652
> #20 0x08053d8b in main (argc=19, argv=0xbffff664) at lfphone.cc:156
> #0  0xffffe410 in __kernel_vsyscall ()
> (gdb)
>
>
>
> >
> > Thanks,
> > Ben
> >
>
>
> -- 
> Ben Greear <[EMAIL PROTECTED]>
> Candela Technologies Inc  http://www.candelatech.com
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by:
> Tame your development challenges with Apache's Geronimo App Server.
> Download it for free - -and be entered to win a 42" plasma tv or your very
> own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
> _______________________________________________
> ooh323c-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ooh323c-devel
>
>




-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. 
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
ooh323c-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ooh323c-devel

Reply via email to