net: sanitize time computation to avoid division by zero
This commit is contained in:
parent
d2a00d7057
commit
8fe4cf436a
10
net.lua
10
net.lua
|
@ -60,13 +60,13 @@ local function worker(format)
|
|||
uformat(args, name .. " up", 0)
|
||||
|
||||
nets[name].time = os.time()
|
||||
else
|
||||
-- Net stats are absolute, substract our last reading
|
||||
local interval = os.time() - nets[name].time
|
||||
else -- Net stats are absolute, substract our last reading
|
||||
local interval = os.time() - nets[name].time > 0 and
|
||||
os.time() - nets[name].time or 1
|
||||
nets[name].time = os.time()
|
||||
|
||||
local down = (recv - nets[name][1])/interval
|
||||
local up = (send - nets[name][2])/interval
|
||||
local down = (recv - nets[name][1]) / interval
|
||||
local up = (send - nets[name][2]) / interval
|
||||
|
||||
uformat(args, name .. " down", down)
|
||||
uformat(args, name .. " up", up)
|
||||
|
|
Loading…
Reference in New Issue