]> hydra-www.ietfng.org Git - acmetensortoys-esp-lua_core/commitdiff
telnetd: diag "restart" command
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Thu, 14 Dec 2017 21:16:41 +0000 (16:16 -0500)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Thu, 14 Dec 2017 21:16:41 +0000 (16:16 -0500)
It's a bit of a pain to restart a node over telnet using "diag exec"
because network callbacks will crash due to races(?) against
node.restart if that's dispatched immediately.  Add a command to
dispatch it "soon".

telnetd/telnetd-diag.lua

index e3b238f0f5501b83bf0c6bf02df4713905a4d361..612171cf4e53e88224edd7981ca476b3702aeb61 100644 (file)
@@ -4,6 +4,9 @@ return {
   ["info"] = function(_,s) s(string.format("major=%d minor=%d dev=%d chip=%d flash=%d fs=%d fm=%d fs=%d",node.info())) end,
   ["heap"] = function(_,s) s(string.format("free=%d",node.heap())) end,
   ["fifo"] = function(_,s) if rtcfifo and rtcfifo.ready() ~= 0 then s(string.format("fifo=%d",rtcfifo.count())) else s("no rtcfifo") end end,
+       -- restart in one tick, so that network callbacks have a chance to fire
+       -- first, or else we might crash.  Ick!
+  ["restart"] = function(_,s) tmr.create():alarm(1, tmr.ALARM_SINGLE, node.restart) end,
   ["exec"] = function(l,s)
        local f, err = loadstring(l)
        if f