mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 01:28:20 +00:00
Fix schedule statements used outside event handlers (addresses #974).
This commit is contained in:
parent
9a88dc500a
commit
fa30d4a313
3 changed files with 13 additions and 4 deletions
|
@ -4297,6 +4297,10 @@ Val* ScheduleExpr::Eval(Frame* f) const
|
||||||
if ( args )
|
if ( args )
|
||||||
{
|
{
|
||||||
TimerMgr* tmgr = mgr.CurrentTimerMgr();
|
TimerMgr* tmgr = mgr.CurrentTimerMgr();
|
||||||
|
|
||||||
|
if ( ! tmgr )
|
||||||
|
tmgr = timer_mgr;
|
||||||
|
|
||||||
tmgr->Add(new ScheduleTimer(event->Handler(), args, dt, tmgr));
|
tmgr->Add(new ScheduleTimer(event->Handler(), args, dt, tmgr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
event statement
|
event statement
|
||||||
event part1
|
event part1
|
||||||
event part2
|
event part2
|
||||||
schedule statement
|
schedule statement in bro_init
|
||||||
|
schedule statement in global
|
||||||
|
schedule statement another in bro_init
|
||||||
|
|
|
@ -9,9 +9,9 @@ event e1()
|
||||||
print "Error: this should not happen";
|
print "Error: this should not happen";
|
||||||
}
|
}
|
||||||
|
|
||||||
event e2()
|
event e2(s: string)
|
||||||
{
|
{
|
||||||
print "schedule statement";
|
print fmt("schedule statement %s", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
event e3(test: string)
|
event e3(test: string)
|
||||||
|
@ -36,7 +36,8 @@ event bro_init()
|
||||||
event e1();
|
event e1();
|
||||||
|
|
||||||
# Test calling an event with "schedule" statement
|
# Test calling an event with "schedule" statement
|
||||||
schedule 1 sec { e2() };
|
schedule 1 sec { e2("in bro_init") };
|
||||||
|
schedule 3 sec { e2("another in bro_init") };
|
||||||
|
|
||||||
# Test calling an event that has two separate definitions
|
# Test calling an event that has two separate definitions
|
||||||
event e3("foo");
|
event e3("foo");
|
||||||
|
@ -47,3 +48,5 @@ event bro_init()
|
||||||
event e5(6); # TODO: this does not do anything
|
event e5(6); # TODO: this does not do anything
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# scheduling in outside of an event handler shouldn't crash.
|
||||||
|
schedule 2sec { e2("in global") };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue