From notifications@github.com Fri Apr 30 19:48:48 2021 From: Giacomo Vacca To: sr-dev@lists.kamailio.org Subject: Re: [sr-dev] [kamailio/kamailio] tm: t_suspend.c - t_continue_helper() - do not continue processing a reply if it's suspended again (#2721) Date: Fri, 30 Apr 2021 10:48:45 -0700 Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1168288488==" --===============1168288488== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable In order to explain why this is needed, I've prepared a new test scenario: ht= tps://github.com/kamailio/kamailio-tests/pull/19 This sees an HTTP request being performed in a reply route, using `http_async= _client` and with suspension of the transaction. Upon landing into the HTTP reply route, the transaction is suspended for a se= cond time while a new `http_async_query()` is performed. Without the change in this PR, the suspension during the second query, even t= hough it's logged as happened, doesn't have effect on `t_continue_helper()` w= hich continues processing the reply. The reply is so sent out and when the HT= TP reply route is reached afterwards the transaction exists but it's already = in terminated state. An example of .cfg (as used in the example test scenario): ``` 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", "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D INVITE_REPL= Y =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\n"); if (status=3D~"200") { http_async_query("http://127.0.0.1:8080/", "HTTP_REPLY1"); } } route[HTTP_REPLY1] { xlog("L_INFO", "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D HTTP_REPLY1= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\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", "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D HTTP_REPLY2= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D DONE\n"); } ``` The debug log before the change: ``` 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 su= spended reply - resetting the suspend branch flag 6(32) INFO: