<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I have a system running Asterisk 11.2.1 that has had a couple calls between internal extensions get “stuck open”. I didn’t catch the verbose log for the first one, since I generally don’t verbosely log to file, but the second one shows
that the call that got stuck was dialed, but the caller hung up before the called device answered.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">This server is running a hotdesking environment, so I am running a GoSub on call completion (and on termination via the h extension) to handle custom device states, in order to provide BLF for the user extensions without having to dynamically
update which device the hints are pointing to. If the timing of the log entries are correct, Asterisk had already determined which device to ring, and dialed that device (firing off the “on call creation” GoSub to set the BLF of the called extension to RINGING),
but then the calling user hung up before the GoSub returned.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Is this something with my dialplan logic? Is this some race condition issue that I’ve stumbled across? What can I do to fix/mitigate the issue? Pertinent dialplan of my internal call handling is below:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">[hotdesk-outbound] ; call from logged in phones comes here first to set CallerID and check permissions of logged in user<o:p></o:p></p>
<p class="MsoNormal">exten => _X.,1,NoOp()<o:p></o:p></p>
<p class="MsoNormal">same => n,Set(LOCATION=${CUT(CHANNEL,/,2)})<o:p></o:p></p>
<p class="MsoNormal">same => n,Set(LOCATION=${CUT(LOCATION,-,1)})<o:p></o:p></p>
<p class="MsoNormal">same => n,Set(WHO=${HOTDESK_PHONE_STATUS(${LOCATION})})<o:p></o:p></p>
<p class="MsoNormal">same => n,GotoIf($[${ISNULL(${WHO})}]?internal,${EXTEN},1)<o:p></o:p></p>
<p class="MsoNormal">same => n,Set(${WHO}_CID_NAME=${HOTDESK_INFO(cid_name,${WHO})})<o:p></o:p></p>
<p class="MsoNormal">same => n,Set(${WHO}_CID_NUMBER=${HOTDESK_INFO(cid_number,${WHO})})<o:p></o:p></p>
<p class="MsoNormal">same => n,Set(${WHO}_OUTBOUND_PERMISSION=${HOTDESK_INFO(permissions,${WHO})})<o:p></o:p></p>
<p class="MsoNormal">same => n,Gosub(blf-begincall,s,1(${WHO},INUSE))<o:p></o:p></p>
<p class="MsoNormal">same => n,Set(CALLERID(name)=${${WHO}_CID_NAME})<o:p></o:p></p>
<p class="MsoNormal">same => n,Set(CALLERID(num)=${${WHO}_CID_NUMBER})<o:p></o:p></p>
<p class="MsoNormal">same => n,Goto(users,${EXTEN},1)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">[users]<o:p></o:p></p>
<p class="MsoNormal">include => internal<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">[internal]<o:p></o:p></p>
<p class="MsoNormal">exten => _1XX,1,Verbose(5,Internal user - ${EXTEN})<o:p></o:p></p>
<p class="MsoNormal">same => n,Set(E=${EXTEN})<o:p></o:p></p>
<p class="MsoNormal">same => n,Set(USER_LOCATION=${HOTDESK_USER_STATUS(${E})})<o:p></o:p></p>
<p class="MsoNormal">same => n,GotoIf($[${ODBCROWS} < 1]?notloggedin)<o:p></o:p></p>
<p class="MsoNormal">same => n,Dial(SIP/${USER_LOCATION},20,wWU(blf-begincall^${E}^INUSE)b(blf-begincall^s^1(${E}^RINGING)))<o:p></o:p></p>
<p class="MsoNormal">same => n,Voicemail(${E}@rsnwo,b)<o:p></o:p></p>
<p class="MsoNormal">same => n,Hangup()<o:p></o:p></p>
<p class="MsoNormal">same => n(notloggedin),Set(LOGGED_OFF=1)<o:p></o:p></p>
<p class="MsoNormal">same => n,Voicemail(${E}@rsnwo,u)<o:p></o:p></p>
<p class="MsoNormal">same => n,Hangup()<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">[blf-begincall]<o:p></o:p></p>
<p class="MsoNormal">exten => s,1,Verbose("Beginning of Call - set BLF Custom Device state")<o:p></o:p></p>
<p class="MsoNormal">same => n,Verbose(Updating: ${ARG1} Calls: ${GROUP_COUNT(${ARG1}@activecalls)} Status: ${ARG2})<o:p></o:p></p>
<p class="MsoNormal">same => n,ExecIf($[${ARG2} = RINGING]?ExecIf($[${GROUP_COUNT(${ARG1}@activecalls)} > 0]?Set(DEVICE_STATE(Custom:${ARG1})=RINGINUSE):Set(DEVICE_STATE(Custom:${ARG1})=RINGING)):Set(DEVICE_STATE(Custom:${ARG1})=INUSE))<o:p></o:p></p>
<p class="MsoNormal">same => n,Set(GROUP(activecalls)=${ARG1})<o:p></o:p></p>
<p class="MsoNormal">same => n,Set(CHANNEL(hangup_handler_wipe)=blf-endcall,s,1(${ARG1}))<o:p></o:p></p>
<p class="MsoNormal">same => n,Return()<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">[blf-endcall]<o:p></o:p></p>
<p class="MsoNormal">exten => s,1,Verbose("End of Call - reset BLF Custom Device state")<o:p></o:p></p>
<p class="MsoNormal">same => n,Verbose(Updating: ${ARG1} Calls: ${GROUP_COUNT(${ARG1}@activecalls)})<o:p></o:p></p>
<p class="MsoNormal">same => n,ExecIf($[${GROUP_COUNT(${ARG1}@activecalls)} > 1]?Set(DEVICE_STATE(Custom:${ARG1})=INUSE):Set(DEVICE_STATE(Custom:${ARG1})=NOT_INUSE))<o:p></o:p></p>
<p class="MsoNormal">same => n,Return()<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thank you,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Noah Engelberth<o:p></o:p></p>
</div>
</body>
</html>