Fix limiting nr of route shows with low memory (#518)

This commit is contained in:
Tim Wilkinson 2022-10-11 20:22:11 -07:00 committed by GitHub
parent c7538884ca
commit 1a0d51ff59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 3 deletions

View File

@ -159,9 +159,8 @@ end
local lowmemory = cursor:get("aredn", "@meshstatus[0]", "lowmem") local lowmemory = cursor:get("aredn", "@meshstatus[0]", "lowmem")
if not lowmemory then if not lowmemory then
lowmemory = 10000 lowmemory = 10000
else
lowmemory = tonumber(lowmemory)
end end
lowmemory = 1024 * tonumber(lowmemory)
local lowroutes = cursor:get("aredn", "@meshstatus[0]", "lowroutes") local lowroutes = cursor:get("aredn", "@meshstatus[0]", "lowroutes")
if not lowroutes then if not lowroutes then
lowroutes = 1000 lowroutes = 1000
@ -208,7 +207,7 @@ if olsr_routes > lowroutes and nixio.sysinfo().freeram < lowmemory then
table.sort(list, function (a, b) return a.etx < b.etx end) table.sort(list, function (a, b) return a.etx < b.etx end)
for i = lowroutes,olsr_routes for i = lowroutes,olsr_routes
do do
table.remove(routes, list[i].key) routes[list[i].key] = nil
end end
end end