<p></p>
<p>In order to explain why this is needed, I've prepared a new test scenario: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="872888196" data-permission-text="Title is private" data-url="https://github.com/kamailio/kamailio-tests/issues/19" data-hovercard-type="pull_request" data-hovercard-url="/kamailio/kamailio-tests/pull/19/hovercard" href="https://github.com/kamailio/kamailio-tests/pull/19">kamailio/kamailio-tests#19</a></p>
<p>This sees an HTTP request being performed in a reply route, using <code>http_async_client</code> and with suspension of the transaction.<br>
Upon landing into the HTTP reply route, the transaction is suspended for a second time while a new <code>http_async_query()</code> is performed.</p>
<p>Without the change in this PR, the suspension during the second query, even though it's logged as happened, doesn't have effect on <code>t_continue_helper()</code> which continues processing the reply. The reply is so sent out and when the HTTP reply route is reached afterwards the transaction exists but it's already in terminated state.</p>
<p>An example of .cfg (as used in the example test scenario):</p>
<pre><code>request_route {
        if (is_request()) {
                if (is_method("INVITE")) {
                        t_newtran();
                        t_on_reply("INVITE_REPLY");
                        t_relay("127.0.0.1", "5080");
                        exit;
                }
                else if (is_method("ACK")) {
                        t_relay("127.0.0.1", "5080");
                        exit;
                }
        }
        drop;
}

onreply_route[INVITE_REPLY] {
        xlog("L_INFO", "================ INVITE_REPLY ==================\n");
        if (status=~"200") {
                http_async_query("http://127.0.0.1:8080/", "HTTP_REPLY1");
        }
}

route[HTTP_REPLY1] {
        xlog("L_INFO", "================ HTTP_REPLY1 ==================\n");
        if ($http_ok) {
                xlog("L_INFO", "HTTP GET REPLY1: $http_rs - Response: $http_rb\n");
                http_async_query("http://127.0.0.1:8080/", "HTTP_REPLY2");
                sl_send_reply("200", "OK");
                exit;
        }
        else {
                xlog("L_ERR", "HTTP error: $http_err\n");
        }
}

route[HTTP_REPLY2] {
        xlog("L_INFO", "================ HTTP_REPLY2 ================== DONE\n");
}
</code></pre>
<p>The debug log before the change:</p>
<pre><code> 6(32) DEBUG: tm [t_lookup.c:1612]: t_lookup_ident_filter(): transaction found
 6(32) DEBUG: http_async_client [async_http.c:235]: async_http_cb(): resuming transaction (44930:409999179)
 6(32) DEBUG: tm [t_lookup.c:1612]: t_lookup_ident_filter(): transaction found
 6(32) DEBUG: tm [t_suspend.c:364]: t_continue_helper(): continuing from a suspended reply - resetting the suspend branch flag

 6(32) INFO: <script>: ================ HTTP_REPLY1 ==================
 6(32) INFO: <script>: HTTP GET REPLY1: 200 - Response:

Now it calls async_send_query():

 6(32) DEBUG: tm [t_suspend.c:113]: t_suspend(): this is a suspend on reply - setting msg flag to SUSPEND
 6(32) DEBUG: tm [t_lookup.c:1034]: t_check_msg(): msg (0x7f48b3cd6b60) id=2/27 global id=2/27 T start=0x7f48b3cd34d8
 6(32) DEBUG: tm [t_lookup.c:1109]: t_check_msg(): T (0x7f48b3cd34d8) already found for msg (0x7f48b3cd6b60)!
 6(32) DEBUG: tm [t_suspend.c:121]: t_suspend(): found a a match with branch id [0] - cloning reply message to t->uac[branch].reply
 6(32) DEBUG: tm [t_suspend.c:133]: t_suspend(): saving transaction data

 6(32) DEBUG: http_async_client [async_http.c:469]: async_send_query(): transaction suspended [44930:409999179]

(index and label are as expected)

 6(32) DEBUG: http_async_client [async_http.c:625]: async_push_query(): query sent [http://127.0.0.1:8080/] (0x7f48b3cdfa08) to worker 1

Here it should have suspended, but it's actually continuing in the reply route:

 6(32) DEBUG: tm [t_suspend.c:408]: t_continue_helper(): restoring previous environment
 6(32) DEBUG: tm [t_suspend.c:435]: t_continue_helper(): t is not local - relaying reply with status code: [200]
</code></pre>

<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/pull/2721#issuecomment-830258187">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZMOUQFNKH52X256C53TLLUP3ANCNFSM4345BDPA">unsubscribe</a>.<img src="https://github.com/notifications/beacon/ABO7UZIDWWKT2J5ZUJCGG7TTLLUP3A5CNFSM4345BDPKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOGF6LYCY.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/pull/2721#issuecomment-830258187",
"url": "https://github.com/kamailio/kamailio/pull/2721#issuecomment-830258187",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>