MT#10601 dlgcnt: remove central counters when it reaches to 0

Change-Id: I67c4339b90fe5862b41b01ca4b3d5352a11e39b4
changes/24/624/1
Victor Seva 11 years ago
parent c225239f37
commit b59bf13125

@ -74,6 +74,17 @@ end
return client; return client;
end end
function NGCPDlgCounters._decr(self, key)
local res = self.central:decr(key);
if res == 0 then
self.central:del(key);
sr.log("dbg", string.format("central:del[%s] counter is 0\n", key));
else
sr.log("dbg", string.format("central:decr[%s]=>[%s]\n", key, tostring(res)));
end
return res;
end
function NGCPDlgCounters:set(callid, key) function NGCPDlgCounters:set(callid, key)
if not self._test_connection(self.central) then if not self._test_connection(self.central) then
self.central = self._connect(self.config.central); self.central = self._connect(self.config.central);
@ -96,8 +107,7 @@ end
if not self._test_connection(self.central) then if not self._test_connection(self.central) then
self.central = self._connect(self.config.central); self.central = self._connect(self.config.central);
end end
local res = self.central:decr(key); self:_decr(key);
sr.log("dbg", string.format("central:decr[%s]=>[%s]\n", key, tostring(res)));
end end
function NGCPDlgCounters:del(callid) function NGCPDlgCounters:del(callid)
@ -111,10 +121,8 @@ end
if not self._test_connection(self.central) then if not self._test_connection(self.central) then
self.central = self._connect(self.config.central); self.central = self._connect(self.config.central);
end end
local res;
while key do while key do
res = self.central:decr(key); self:_decr(key);
sr.log("dbg", string.format("central:decr[%s]=>[%s]\n", key, tostring(res)));
sr.log("dbg", string.format("pair:lpop[%s]=>[%s]\n", callid, key)); sr.log("dbg", string.format("pair:lpop[%s]=>[%s]\n", callid, key));
key = self.pair:lpop(callid); key = self.pair:lpop(callid);
end end

Loading…
Cancel
Save