Summary:ASTERISK-15250: LOCK behaves like trylock (not waiting for 3 seconds)
Reporter:Peter Holik (peterh)Labels:
Date Opened:2009-12-01 03:58:32.000-0600Date Closed:2017-10-23 22:29:10
Versions:Frequency of
Description:I thought LOCK will try to get the lock and wait up to 3 seconds to get the lock.

First Caller A calls a context with a LOCK statement and waits.
Then Caller B calls the same context and i see that LOCK is finished immediately.


exten => 222,1,GotoIf(${TRYLOCK(mylock)}?:locked)
exten => 222,n,Noop(got lock)
exten => 222,n,Wait(30)
exten => 222,n,Hangup
exten => 222,n(locked),Noop(is locked)
exten => 222,n,Hangup

  -- Executing [222@default:1] GotoIf("SIP/callera-0000017c", "1?:locked") in new stack
   -- Executing [222@default:2] NoOp("SIP/callera-0000017c", "got lock") in new stack
   -- Executing [222@default:3] Wait("SIP/callera-0000017c", "30") in new stack
 == Using SIP RTP CoS mark 5
   -- Executing [222@default:1] GotoIf("SIP/callerb-0000017d", "0?:locked") in new stack
   -- Goto (default,222,5)
   -- Executing [222@default:5] NoOp("SIP/callerb-0000017d", "is locked") in new stack
   -- Executing [222@default:6] Hangup("SIP/callerb-0000017d", "") in new stack
 == Spawn extension (default, 222, 6) exited non-zero on 'SIP/callerb-0000017d'

Comments:By: Tilghman Lesher (tilghman) 2009-12-01 10:01:15.000-0600

Um, you say that you're using LOCK(), but your example shows using TRYLOCK().

By: Peter Holik (peterh) 2009-12-02 02:49:46.000-0600

sorry posted wrong example (got influenza)

You are right -> please use LOCK instead of TRYLOCK:

But the results are the same (no wait for 3 seconds in LOCK)

exten => 221,1,GotoIf(${LOCK(mylock)}?:locked)
exten => 221,n,Noop(got lock)
exten => 221,n,Wait(30)
exten => 221,n,Hangup
exten => 221,n(locked),Noop(is locked)
exten => 221,n,Hangup

By: laszlovl (lvl) 2012-03-20 09:02:58.841-0500

This bug is still present in the latest trunk version: LOCK returns 0 instantly without waiting for 3 seconds.

[Mar 20 11:48:20] VERBOSE[2836] pbx.c:     -- Executing [s@callphone:3] NoOp("Local/567@phones-74ba;2", "Lock 567: 1") in new stack
[Mar 20 11:48:20] VERBOSE[2838] pbx.c:     -- Executing [s@callphone:3] NoOp("Local/567@phones-8c73;2", "Lock 567: 0") in new stack

By: Sean Bright (seanbright) 2017-08-23 10:07:28.004-0500

I'm not able to reproduce this in Asterisk 13. Can you try with Asterisk 13 or newer and let us know if you are still having this issue?

By: Corey Farrell (coreyfarrell) 2017-10-23 22:29:03.238-0500

Looks like this was fixed by ASTERISK-16868.