mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 10:38:20 +00:00
Allow arbitrary when statement timeout expressions
BIT-1284 #close
This commit is contained in:
parent
285f93b689
commit
2a181a88c5
4 changed files with 24 additions and 6 deletions
5
CHANGES
5
CHANGES
|
@ -1,4 +1,9 @@
|
||||||
|
|
||||||
|
2.3-267 | 2014-10-31 10:35:02 -0500
|
||||||
|
|
||||||
|
* BIT-1284: Allow arbitrary when statement timeout expressions
|
||||||
|
(Jon Siwek)
|
||||||
|
|
||||||
2.3-266 | 2014-10-31 09:21:28 -0500
|
2.3-266 | 2014-10-31 09:21:28 -0500
|
||||||
|
|
||||||
* BIT-1166: Add configure options to fine tune local state dirs used
|
* BIT-1166: Add configure options to fine tune local state dirs used
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
2.3-266
|
2.3-267
|
||||||
|
|
|
@ -131,18 +131,19 @@ Trigger::Trigger(Expr* arg_cond, Stmt* arg_body, Stmt* arg_timeout_stmts,
|
||||||
arg_frame->SetDelayed();
|
arg_frame->SetDelayed();
|
||||||
}
|
}
|
||||||
|
|
||||||
Val* timeout = arg_timeout ? arg_timeout->ExprVal() : 0;
|
Val* timeout_val = arg_timeout ? arg_timeout->Eval(arg_frame) : 0;
|
||||||
|
|
||||||
// Make sure we don't get deleted if somebody calls a method like
|
// Make sure we don't get deleted if somebody calls a method like
|
||||||
// Timeout() while evaluating the trigger.
|
// Timeout() while evaluating the trigger.
|
||||||
Ref(this);
|
Ref(this);
|
||||||
|
|
||||||
if ( ! Eval() && timeout )
|
if ( ! Eval() && timeout_val )
|
||||||
{
|
{
|
||||||
timer = new TriggerTimer(timeout->AsInterval(), this);
|
timer = new TriggerTimer(timeout_val->AsInterval(), this);
|
||||||
timer_mgr->Add(timer);
|
timer_mgr->Add(timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Unref(timeout_val);
|
||||||
Unref(this);
|
Unref(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,25 @@
|
||||||
|
|
||||||
event bro_init()
|
event bro_init()
|
||||||
{
|
{
|
||||||
local h1: addr = 127.0.0.1;
|
local h: addr = 127.0.0.1;
|
||||||
|
|
||||||
when ( local h1name = lookup_addr(h1) )
|
when ( local hname = lookup_addr(h) )
|
||||||
{
|
{
|
||||||
print "lookup successful";
|
print "lookup successful";
|
||||||
terminate();
|
terminate();
|
||||||
}
|
}
|
||||||
|
timeout 10sec
|
||||||
|
{
|
||||||
|
print "timeout (1)";
|
||||||
|
}
|
||||||
|
|
||||||
|
local to = 5sec;
|
||||||
|
# Just checking that timeouts can use arbitrary expressions...
|
||||||
|
when ( local hname2 = lookup_addr(h) ) {}
|
||||||
|
timeout to {}
|
||||||
|
when ( local hname3 = lookup_addr(h) ) {}
|
||||||
|
timeout to + 2sec {}
|
||||||
|
|
||||||
print "done";
|
print "done";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue