<h2>Environment</h2>

<p>Kamailio 4.3.3<br>
Ubuntu 14.04.1 x86_64</p>

<h2>Problem</h2>

<p>I'm using <code>t_suspend()</code> and <code>t_continue()</code> for mobile push notification scenario. Before calling <code>t_suspend()</code> I set the <code>fr_timer</code> to 12 seconds and <code>t_on_failure()</code> to my custom failure route (e.g. <code>failure_route[MY_FAILURE_ROUTE]</code>). The scenario is fairly similar to <a href="http://lists.sip-router.org/pipermail/sr-users/2015-March/087519.html">[SR-Users] Timeout after t_suspend and failure route</a>, the only difference is I try to use <code>jsonrpc_notificaion()</code> to notify the user asynchronously in my custom failure route.</p>

<p>There are 2 different results depending on how it goes to the failure route:</p>

<ol>
<li>Caller cancel the call before <code>fr_timer</code> expires

<ul>
<li>
<code>jsonrpc_notification</code> can successfully be called in failure route</li>
</ul>
</li>
<li>The <code>fr_timer</code> did timeout after 12 seconds

<ul>
<li>An error occurred while calling <code>jsonrpc_notification</code>:</li>
<li><code>jsonrpc_notification(): failed to write to io pipe: Bad file descriptor</code></li>
</ul>
</li>
</ol>

<h2>Investigation</h2>

<p>For the first case that perform normally, the IDs of Kamailio processes being used are the same for both <strong>calling t_suspend()</strong> and <strong>entering failure route</strong>, while in the second case the processes are different.</p>

<p>Following added some debug messages in Kamailio's <code>main.c</code> it showed that the process being used in the failure route of case 2 is <code>slow timer process</code>, and from <code>jsonrpc_mod.c</code>'s <code>child_init()</code> function, the rank of <code>slow timer process</code> is <strong>-1</strong> therefore it doesn't assign the <code>fd</code> to this process.</p>

<p>My workaround was just assigning the <code>fd</code> to each child during <code>child_init()</code> in <code>jsonrpc_mod.c</code> but that's definitely not a good way to go. I am appreciated if you can give me some advice to solve this problem correctly.</p>

<p>Cheers,<br>
Ian</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/713">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AF36ZXLOG9wP_KJHHdPMZ51gyMWJWE55ks5qWJ-AgaJpZM4JN-WS">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AF36ZTp_eV3Jn5fnr4TJTHfgVwoViffsks5qWJ-AgaJpZM4JN-WS.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/kamailio/kamailio/issues/713"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>