made stuff use computer.uptime because it always returns seconds
This commit is contained in:
parent
f0a175762b
commit
21a9c66d8d
@ -14,11 +14,11 @@ local function nshcw(h,p)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
net.send(h,p,"initnsh2")
|
net.send(h,p,"initnsh2")
|
||||||
local bt = os.time()
|
local bt = computer.uptime()
|
||||||
local tp,src,port,msg
|
local tp,src,port,msg
|
||||||
repeat
|
repeat
|
||||||
tp, src, port, msg = event.pull()
|
tp, src, port, msg = event.pull()
|
||||||
until (tp == "net_msg" and src == h and port == p) or os.time() > bt+16
|
until (tp == "net_msg" and src == h and port == p) or computer.uptime() > bt+16
|
||||||
if tp == "net_msg" then
|
if tp == "net_msg" then
|
||||||
nshcw(h,tonumber(msg))
|
nshcw(h,tonumber(msg))
|
||||||
else
|
else
|
||||||
|
@ -44,17 +44,17 @@ spawn("copperd",function() print(xpcall(function ()
|
|||||||
p.msg = ev[4]
|
p.msg = ev[4]
|
||||||
p.at = 0
|
p.at = 0
|
||||||
p.lt = 0
|
p.lt = 0
|
||||||
pt[cdlib.encode(0,net.id,p.nid,relib.encode(p)):sub(2)] = os.time()
|
pt[cdlib.encode(0,net.id,p.nid,relib.encode(p)):sub(2)] = computer.uptime()
|
||||||
ps[p.pid] = p
|
ps[p.pid] = p
|
||||||
elseif ev[1] == "modem_message" and ev[4] == net.np and ev[6] == "copper" then
|
elseif ev[1] == "modem_message" and ev[4] == net.np and ev[6] == "copper" then
|
||||||
local hops,src,dst,data = cdlib.decode(ev[7])
|
local hops,src,dst,data = cdlib.decode(ev[7])
|
||||||
if hops and src and dst and data then
|
if hops and src and dst and data then
|
||||||
if not fcache[src] then
|
if not fcache[src] then
|
||||||
log("fcache["..tostring(src).."] = "..tostring(ev[3]))
|
log("fcache["..tostring(src).."] = "..tostring(ev[3]))
|
||||||
fcache[src] = {ev[2],ev[3],os.time()}
|
fcache[src] = {ev[2],ev[3],computer.uptime()}
|
||||||
end
|
end
|
||||||
if not pt[ev[7]:sub(2)] then
|
if not pt[ev[7]:sub(2)] then
|
||||||
pt[ev[7]:sub(2)] = os.time()
|
pt[ev[7]:sub(2)] = computer.uptime()
|
||||||
if dst == net.id then
|
if dst == net.id then
|
||||||
event.push("net_rmsg",src,data)
|
event.push("net_rmsg",src,data)
|
||||||
local pd = relib.decode(data)
|
local pd = relib.decode(data)
|
||||||
@ -89,7 +89,7 @@ spawn("copperd",function() print(xpcall(function ()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
for k,v in pairs(ps) do
|
for k,v in pairs(ps) do
|
||||||
if v.lt < os.time()-1 then
|
if v.lt < computer.uptime()-1 then
|
||||||
if fcache[v.nid] and net.cache then
|
if fcache[v.nid] and net.cache then
|
||||||
local lma = fcache[v.nid][1]
|
local lma = fcache[v.nid][1]
|
||||||
local rma = fcache[v.nid][2]
|
local rma = fcache[v.nid][2]
|
||||||
@ -100,14 +100,14 @@ spawn("copperd",function() print(xpcall(function ()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
v.at = v.at + 1
|
v.at = v.at + 1
|
||||||
v.lt = os.time()
|
v.lt = computer.uptime()
|
||||||
if v.pt == 2 then ps[k] = nil end
|
if v.pt == 2 then ps[k] = nil end
|
||||||
end
|
end
|
||||||
if v.at > 255 then
|
if v.at > 255 then
|
||||||
ps[k] = nil
|
ps[k] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local cot = os.time()
|
local cot = computer.uptime()
|
||||||
for k,v in pairs(pt) do
|
for k,v in pairs(pt) do
|
||||||
if v < cot-16 then
|
if v < cot-16 then
|
||||||
pt[k] = nil
|
pt[k] = nil
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
spawn("logflushd",function()
|
spawn("logflushd",function()
|
||||||
local lt = os.time()
|
local lt = computer.uptime()
|
||||||
while true do
|
while true do
|
||||||
if os.time() > lt + 60 and Log:len() > 0 then
|
if computer.uptime() > lt + 60 and Log:len() > 0 then
|
||||||
local f = fs.open("/tmp/sys.log","ab")
|
local f = fs.open("/tmp/sys.log","ab")
|
||||||
if f then
|
if f then
|
||||||
for i = 1, #Log, 1024 do
|
for i = 1, #Log, 1024 do
|
||||||
|
Loading…
Reference in New Issue
Block a user