<p>Hi All,</p>

<p>I've been doing some work this week with the new http_async_client module, it seems that with it's default behaviour it's not possible to execute another async query in the block immediately following the response, for example the following config:</p>

<pre><code>request_route {
  if (!t_newtran()) {
      sl_reply_error();
      exit();
  }
  http_async_query("http://localhost:8090/req_1", '{"user":"$fU"}', "REQ_1");
}

route[REQ_1] {
  xlog("L_INFO", "route[REQ_1]: INIT\n");
  if ($http_ok) {
    xlog("L_INFO", "route[REQ_1]: status $http_rs\n");
    xlog("L_INFO", "route[REQ_1]: Sending REQ_2\n");
    http_async_query("http://localhost:8090/req_2", '{"user":"$fU"}', "REQ_2");
  } else {
    xlog("L_INFO", "route[REQ_1]: error  $http_err)\n");
  }
}

route[REQ_2] {
  xlog("L_INFO", "route[REQ_2]: INIT\n");
  if ($http_ok) {
    xlog("L_INFO", "route[REQ_2]: status $http_rs\n");
  } else {
    xlog("L_INFO", "route[REQ_2]: error  $http_err)\n");
  }
}
</code></pre>

<p>Generates the following error:</p>

<pre><code>10(11832) INFO: <script>: route[REQ_1]: INIT
10(11832) INFO: <script>: route[REQ_1]: status 200
10(11832) INFO: <script>: route[REQ_1]: Sending REQ_2
10(11832) WARNING: tm [t_suspend.c:186]: t_continue(): transaction is not suspended [53195:560306836]
</code></pre>

<p>Looking at the source, http_async_client calls t_suspend, then goes away and performs the request in the background. On response it calls t_continue and then this block in t_continue will continue execution, the second query will cause http_async_client to call t_suspend whilst sill executing from the previous t_continue. Once they query is sent, the first t_continue will complete, removing the T_ASYNC_SUSPENDED flag. When the second query returns it doesn't find the flag and so fails as shown.</p>

<p>I'm far from an expect on this so would really appreciate some pointers, it seems to fundamental to be a race condition in tm but the usage in http_async_client seems to match usage in other modules so I'm not sure on the best tactic.<br>
I've tried peppering append_branch and async_route call's in various places to no avail.</p>

<p>Full debug log here: <a href="http://pastebin.com/raw/rFmm0fmf">http://pastebin.com/raw/rFmm0fmf</a></p>

<p>Any help appreciated,</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/645">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe/AF36ZT5APFjvOrGuDs6V6Gg1p-pYEQjtks5qGVocgaJpZM4IpP9_">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AF36ZTeaPfwUQqU25x7DfOYGPJzTB6-1ks5qGVocgaJpZM4IpP9_.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/645"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>