Hi All,
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:
```
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");
}
}
```
Generates the following error:
```
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]
```
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.
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.
I've tried peppering append_branch and async_route call's in various places to no avail.
Full debug log here: http://pastebin.com/raw/rFmm0fmf
Any help appreciated,
---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/645
Hi,
I am a newbie here. i am using Kamailio version 4.4 on CentOS 6.
i need configuration to send INVITE encapsulate ISUP.
Please guide me about this configuaration.
Thank you.
---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/641
Module: kamailio
Branch: master
Commit: 827ec4fc2c9fcc2bf9f814b0545ae64784d8e3b0
URL: https://github.com/kamailio/kamailio/commit/827ec4fc2c9fcc2bf9f814b0545ae64…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2016-05-30T11:54:34+02:00
tm: reset T_ASYNC_SUSPENDED flag at beginning of t_continue()
- should allow doing t_suspend() inside the route executed by
t_continue()
- related to GH #644 and #645
---
Modified: modules/tm/t_suspend.c
---
Diff: https://github.com/kamailio/kamailio/commit/827ec4fc2c9fcc2bf9f814b0545ae64…
Patch: https://github.com/kamailio/kamailio/commit/827ec4fc2c9fcc2bf9f814b0545ae64…
---
diff --git a/modules/tm/t_suspend.c b/modules/tm/t_suspend.c
index 61f742d..828aa38 100644
--- a/modules/tm/t_suspend.c
+++ b/modules/tm/t_suspend.c
@@ -204,8 +204,11 @@ int t_continue(unsigned int hash_index, unsigned int label,
t->flags |= T_ASYNC_CONTINUE; /* we can now know anywhere in kamailio
* that we are executing post a suspend */
+ /* transaction is no longer suspended, resetting the SUSPEND flag */
+ t->flags &= ~T_ASYNC_SUSPENDED;
+
/* which route block type were we in when we were suspended */
- cb_type = FAILURE_CB_TYPE;;
+ cb_type = FAILURE_CB_TYPE;
switch (t->async_backup.backup_route) {
case REQUEST_ROUTE:
cb_type = FAILURE_CB_TYPE;
@@ -231,7 +234,6 @@ int t_continue(unsigned int hash_index, unsigned int label,
/* Either t_continue() has already been
* called or the branch has already timed out.
* Needless to continue. */
- t->flags &= ~T_ASYNC_SUSPENDED;
UNLOCK_ASYNC_CONTINUE(t);
UNREF(t); /* t_unref would kill the transaction */
return 1;
@@ -456,14 +458,10 @@ int t_continue(unsigned int hash_index, unsigned int label,
t->uac[branch].reply = 0;
}
- /*This transaction is no longer suspended so unsetting the SUSPEND flag*/
- t->flags &= ~T_ASYNC_SUSPENDED;
-
return 0;
kill_trans:
- t->flags &= ~T_ASYNC_SUSPENDED;
/* The script has hopefully set the error code. If not,
* let us reply with a default error. */
if ((kill_transaction_unsafe(t,
I'm trying to have an external application to write CDR to a database by doing this:
event_route[dialog:start] {
evapi_relay("{'cdr_id': $dlg_var(cdr_id), 'event': 'answered'}");
}
event_route[dialog:end] {
evapi_relay("{'cdr_id': $dlg_var(cdr_id), 'event': 'ended'}");
}
event_route[dialog:failed] {
evapi_relay("{'cdr_id': $dlg_var(cdr_id), 'event': 'failed'}");
}
$dlg_var(cdr_id) is set inside a request route. However, in these event routes, its value is always null. Its seems that $dlg_var variables are not available in those event routes.
---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/646
Hi,
Has anyone experienced segfault using http_async_query from
http_async_client module? Here is BT:
#0 __GI_fgets_unlocked (buf=0x7fca23ffe660 "127.0.0.1", n=n@entry=1032,
fp=0x7fca23ffe660) at iofgets_u.c:53
53 iofgets_u.c: No such file or directory.
(gdb) bt
#0 __GI_fgets_unlocked (buf=0x7fca23ffe660 "127.0.0.1", n=n@entry=1032,
fp=0x7fca23ffe660) at iofgets_u.c:53
#1 0x00007fca68f08afa in get_contents (stream=<optimized out>, len=1032,
linebuf=0x7fca23ffe660 "127.0.0.1") at nss_files/files-XXX.c:201
#2 internal_getent (result=0x7fca23ffe5c0, buffer=buffer@entry=0x7fca23ffe640
"\177", buflen=buflen@entry=1064, errnop=errnop@entry=0x7fca23ffebb0,
herrnop=herrnop@entry=0x7fca23ffec00, af=af@entry=0,
flags=flags@entry=0) at nss_files/files-XXX.c:246
#3 0x00007fca68f09ca3 in _nss_files_gethostbyname4_r
(name=name@entry=0x7fca2e790fa0
"localhost", pat=pat@entry=0x7fca23ffebe0, buffer=buffer@entry=0x7fca23ffe640
"\177", buflen=buflen@entry=1064,
errnop=errnop@entry=0x7fca23ffebb0, herrnop=herrnop@entry=0x7fca23ffec00,
ttlp=ttlp@entry=0x0) at nss_files/files-hosts.c:402
#4 0x00007fca79eb7757 in gaih_inet (name=<optimized out>,
name@entry=0x7fca2e790fa0
"localhost", service=<optimized out>, req=req@entry=0x7fca341c7490,
pai=pai@entry=0x7fca23ffed10,
naddrs=naddrs@entry=0x7fca23ffed00) at
../sysdeps/posix/getaddrinfo.c:850
#5 0x00007fca79ebae0d in __GI_getaddrinfo (name=0x7fca2e790fa0
"localhost", service=0x7fca23ffeec0 "18000", hints=0x7fca341c7490,
pai=0x7fca23ffee78) at ../sysdeps/posix/getaddrinfo.c:2406
#6 0x00007fca6e0f80f4 in ?? () from /usr/lib/x86_64-linux-gnu/libcurl.so.4
#7 0x00007fca6e104fa4 in ?? () from /usr/lib/x86_64-linux-gnu/libcurl.so.4
#8 0x00007fca6e10284b in ?? () from /usr/lib/x86_64-linux-gnu/libcurl.so.4
#9 0x00007fca723c9182 in start_thread (arg=0x7fca23fff700) at
pthread_create.c:312
#10 0x00007fca79ee547d in clone () at
../sysdeps/unix/sysv/linux/x86_64/clone.S:111
Camille, are you maintaining this module now?