Skip to content

Commit

Permalink
engine: allow timely timeline initialization
Browse files Browse the repository at this point in the history
This fixes a bug where the the timeline was initialized before one
had the opportunity to set timeline.enabled
  • Loading branch information
eugeneia committed Mar 15, 2023
1 parent fcfa3e8 commit 00287bb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/core/app.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function timeline ()
timeline_log = timeline_mod.new("events.timeline")
timeline_mod.rate(timeline_log, 9) -- initially log events with rate >= 9
events = timeline_mod.load_events(timeline_log, "core.engine")
packet.initialize_events()
end
return timeline_log
end
Expand Down Expand Up @@ -267,6 +268,8 @@ end

-- Return the configuration actions needed to migrate from old config to new.
function compute_config_actions (old, new)
timeline() -- Ensure timeline is created and initialized

local actions = {}

-- First determine the links that are going away and remove them.
Expand Down Expand Up @@ -333,6 +336,8 @@ end

-- Update the active app network by applying the necessary actions.
function apply_config_actions (actions)
timeline() -- Ensure timeline is created and initialized

-- Table of functions that execute config actions
local ops = {}
-- As an efficiency hack, some apps rely on the fact that we add
Expand Down
4 changes: 3 additions & 1 deletion src/core/packet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ function initialize (max_packets)
shm.unlink("engine/packets.freelist")
end
packets_fl = freelist_create("engine/packets.freelist", max_packets)

end

function initialize_events ()
if not events then
events = timeline.load_events(engine.timeline(), "core.packet")
end
Expand Down
6 changes: 4 additions & 2 deletions src/lib/ptree/worker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ local channel = require("lib.ptree.channel")
local action_codec = require("lib.ptree.action_codec")
local ptree_alarms = require("lib.ptree.alarms")
local timeline = require("core.timeline")
local events = timeline.load_events(engine.timeline(), "core.engine")
local events

local Worker = {}

Expand Down Expand Up @@ -105,7 +105,9 @@ function Worker:main ()

if not engine.auditlog_enabled then engine.enable_auditlog() end

engine.timeline()
if not events then
events = timeline.load_events(engine.timeline(), "core.engine")
end

engine.enable_tick()

Expand Down

0 comments on commit 00287bb

Please sign in to comment.