lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Umm, I think so.  I'm not much of a programmer, but I'll post the
sample script that I'm using for testing.  It seems fairly basic.

=============Begin Script==============
#!/usr/local/bin/lua

require "luasql.mysql"

if string.len(params:getHeader("Caller-Destination-Number")) == 12 then
  dialednpanxx = string.sub(params:getHeader("Caller-Destination-Number"), 3, 8)
elseif  string.len(params:getHeader("Caller-Destination-Number")) == 11 then
  dialednpanxx = string.sub(params:getHeader("Caller-Destination-Number"), 2, 7)
elseif  string.len(params:getHeader("Caller-Destination-Number")) == 10 then
  dialednpanxx = string.sub(params:getHeader("Caller-Destination-Number"), 1, 6)
else dialednpanxx = 999999
end


env = assert (luasql.mysql())
con = assert (env:connect("call_routing","root","password"))
cur = assert (con:execute("SELECT * FROM footprints WHERE npanxx='" ..
dialednpanxx  .. "' ORDER BY rate ASC"))
row = cur:fetch ({}, "a")

xmldialplanERROR = [[
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="freeswitch/xml">
  <section name="result">
    <result status="not found" />
  </section>
</document>
]]

cur:close()
con:close()
env:close()

XML_STRING = xmldialplanERROR
=============Begin Script==============

On Mon, Jul 7, 2008 at 10:46 PM, Javier Guerra Giraldez
<javier@guerrag.com> wrote:
> On Monday 07 July 2008, Adam Twardowski wrote:
>> Basically all I'm doing is having FreeSwitch call a lua script, which
>> calls a select statment on a mysql database, and then returns control
>> back to Freeswitch.
>
> i don't know about freeswitch, but in 99% of cases when you see unbounded
> memory consumption in Lua, the culprit is a userdata that holds only a
> pointer to a much heavier resource.  in those cases the garbage collection
> don't have any hint that it really should begin collecting ASAP
>
> in your case, it might be the DB connection.  are you sure it's being closed
> as many times as it's opened?
>
>
> --
> Javier
>