From damm@sipgate.de Wed Jun 28 13:39:30 2017 From: Sebastian Damm To: sr-users@lists.kamailio.org Subject: [SR-Users] Using lock() correctly Date: Wed, 28 Jun 2017 13:39:07 +0200 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0460514796==" --===============0460514796== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Hi, for a project I need to make sure, I have a setup where I get mirror-traffic into Kamailio which has to do something with it. To work correctly, I need to make sure, the initial INVITE is processed correctly before any reply to the same call. So I thought I use lock() and unlock() for it. This is what the relevant kamailio.cfg part looks like: request_route { xlog("L_INFO", "Got new packet $rm: $si => $Ri\n"); route(li); } onreply_route { xlog("L_INFO", "Got new packet $rm: $si => $Ri - Reply Code $rs\n"); route(li); } route[magic] { lock("$ci"); xlog("L_INFO", "Obtained lock, calling lua...\n"); if(!lua_run("handle_packet")) { xlog("L_ERR", "SCRIPT: failed to execute lua function!\n"); } unlock("$ci"); xlog("L_INFO", "Lua finished, released lock...\n"); drop; exit; } And this is what the log says: Jun 28 13:27:04 busch /usr/sbin/kamailio[18836]: INFO: