Hello,

I think that append_branch() is not exported directly to lua and calling it via sr.modf() can expose you to memory leaks

Adding a new branch is possible via pseudo-variable, your sequence of functions is same as:

$ru = "sip:a@example.com";
$branch(uri) = "sip:b@example.com";
$branch(uri) = "sip:c@example.com";
$branch(uri) = "sip:d@example.com";

In lua, you can use:

http://www.kamailio.org/wiki/embeddedapi/devel/lua#srpvsets

That should be safer.

Cheers,
Daniel

On 31/12/14 19:24, J Lee wrote:
I would like to know if there's a way to do parallel forking via lua code.

So specifically, I'd like to be able to do something like this:
  seturi("sip:a@example.com");
  append_branch("sip:b@example.com");
  append_branch("sip:c@example.com");
  append_branch("sip:d@example.com");

  t_relay();

except via lua, because the list of branches is dynamic. I've tried the following: 

   sr.modf("append_branch","sip:10.x.x.x")

but the error message I'm getting is: 
/usr/sbin/kamailio[7437]: ERROR: app_lua [app_lua_sr.c:177]: lua_sr_modf(): function 'append_branch' is not available 

Just wondering if I "should" be able to do this. 
I've been reading http://www.kamailio.org/wiki/embeddedapi/devel/lua#srtm_package but haven't seen any references to append_branch. 

The other alternative I'm looking at is to just use lua to generate the list of destinations and pass back a hashtable of sorts to
the cfg file. Then from there I will try to loop through the hashtable and do the append_branch command for each entry
in the table. 

If you have other suggestions, I'd appreciate it. 
Thanks. 


_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda