<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>Hello,</p>
<p>I saw you opened an issue on github on this topic -- let's
continue there the discussion.</p>
<p>Cheers,<br>
Daniel<br>
</p>
<br>
<div class="moz-cite-prefix">On 26/05/16 19:05, Thom Seddon wrote:<br>
</div>
<blockquote
cite="mid:CAAXCLupeJbEHZ=fPBwQmurEn9cM2suYXQ4xyKo9vQC3O-xfE-Q@mail.gmail.com"
type="cite">
<div dir="ltr">Hi All,
<div><br>
</div>
<div>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:<br>
<br>
<div><font face="monospace, monospace">request_route {</font></div>
<div><font face="monospace, monospace"> if (!t_newtran()) {</font></div>
<div><font face="monospace, monospace"> sl_reply_error();</font></div>
<div><font face="monospace, monospace"> exit();</font></div>
<div><font face="monospace, monospace"> }</font></div>
<div><font face="monospace, monospace"> http_async_query("<a
moz-do-not-send="true"
href="http://localhost:8090/req_1"><a class="moz-txt-link-freetext" href="http://localhost:8090/req_1">http://localhost:8090/req_1</a></a>",
'{"user":"$fU"}', "REQ_1");</font></div>
<div><font face="monospace, monospace">}</font></div>
<div><font face="monospace, monospace"><br>
</font></div>
<div><font face="monospace, monospace">route[REQ_1] {</font></div>
<div><font face="monospace, monospace"> xlog("L_INFO",
"route[REQ_1]: INIT\n");</font></div>
<div><font face="monospace, monospace"> if ($http_ok) {</font></div>
<div><font face="monospace, monospace"> xlog("L_INFO",
"route[REQ_1]: status $http_rs\n");</font></div>
<div><font face="monospace, monospace"> xlog("L_INFO",
"route[REQ_1]: Sending REQ_2\n");</font></div>
<div><font face="monospace, monospace"> http_async_query("<a
moz-do-not-send="true"
href="http://localhost:8090/req_2"><a class="moz-txt-link-freetext" href="http://localhost:8090/req_2">http://localhost:8090/req_2</a></a>",
'{"user":"$fU"}', "REQ_2");</font></div>
<div><font face="monospace, monospace"> } else {</font></div>
<div><font face="monospace, monospace"> xlog("L_INFO",
"route[REQ_1]: error $http_err)\n");</font></div>
<div><font face="monospace, monospace"> }</font></div>
<div><font face="monospace, monospace">}</font></div>
<div><font face="monospace, monospace"><br>
</font></div>
<div><font face="monospace, monospace">route[REQ_2] {</font></div>
<div><font face="monospace, monospace"> xlog("L_INFO",
"route[REQ_2]: INIT\n");</font></div>
<div><font face="monospace, monospace"> if ($http_ok) {</font></div>
<div><font face="monospace, monospace"> xlog("L_INFO",
"route[REQ_2]: status $http_rs\n");</font></div>
<div><font face="monospace, monospace"> } else {</font></div>
<div><font face="monospace, monospace"> xlog("L_INFO",
"route[REQ_2]: error $http_err)\n");</font></div>
<div><font face="monospace, monospace"> }</font></div>
<div><font face="monospace, monospace">}</font></div>
<div><font face="monospace, monospace"><br>
</font></div>
<div><font face="arial, helvetica, sans-serif">Generates the
following error:</font></div>
<div><font face="monospace, monospace"><br>
</font></div>
<div>
<div style="font-family:monospace,monospace">10(11832) INFO:
<script>: route[REQ_1]: INIT</div>
<div style="font-family:monospace,monospace">10(11832) INFO:
<script>: route[REQ_1]: status 200</div>
<div style="font-family:monospace,monospace">10(11832) INFO:
<script>: route[REQ_1]: Sending REQ_2</div>
<div style="font-family:monospace,monospace">10(11832)
WARNING: tm [t_suspend.c:186]: t_continue(): transaction
is not suspended [53195:560306836]</div>
<div style="font-family:monospace,monospace"><br>
</div>
</div>
<div><font face="arial, helvetica, sans-serif">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 <a moz-do-not-send="true"
href="https://github.com/kamailio/kamailio/blob/4.4/modules/tm/t_suspend.c#L270-L275">this
block</a> 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.</font></div>
<div><font face="arial, helvetica, sans-serif"><br>
</font></div>
<div><font face="arial, helvetica, sans-serif">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.</font></div>
<div><font face="arial, helvetica, sans-serif">I've tried
peppering append_branch and async_route call's in various
places to no avail.</font></div>
<div><font face="arial, helvetica, sans-serif"><br>
</font></div>
<div><font face="arial, helvetica, sans-serif">Full debug log
here: <a moz-do-not-send="true"
href="http://pastebin.com/raw/rFmm0fmf">http://pastebin.com/raw/rFmm0fmf</a></font></div>
<div><font face="arial, helvetica, sans-serif"><br>
</font></div>
<div><font face="arial, helvetica, sans-serif">Any help
appreciated,</font></div>
<div>
<div class="gmail_signature">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<p style="color:rgb(136,136,136)"><b
style="color:rgb(0,0,0);font-family:arial,helvetica,sans-serif;font-size:small">Thom
Seddon</b></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Daniel-Constantin Mierla
<a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a> - <a class="moz-txt-link-freetext" href="http://www.kamailio.org">http://www.kamailio.org</a>
<a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a></pre>
</body>
</html>