add some missing "when" closures

This commit is contained in:
Vern Paxson 2022-05-12 13:39:26 -07:00
parent 025b9b1534
commit 8928aa57e7
6 changed files with 11 additions and 11 deletions

View file

@ -10,7 +10,7 @@ global result_count = 0;
function print_keys(a: opaque of Broker::Store) function print_keys(a: opaque of Broker::Store)
{ {
when ( local s = Broker::keys(a) ) when [a] ( local s = Broker::keys(a) )
{ {
print "keys", s; print "keys", s;
++result_count; ++result_count;

View file

@ -12,7 +12,7 @@ global step: count = 0;
function print_index(k: any) function print_index(k: any)
{ {
when ( local r = Broker::get(h, k) ) when [k] ( local r = Broker::get(h, k) )
{ {
step += 1; step += 1;
print fmt("[%d]", step), k, r$status, r$result; print fmt("[%d]", step), k, r$status, r$result;
@ -26,7 +26,7 @@ function print_index(k: any)
function print_exists(k: any) function print_exists(k: any)
{ {
when ( local r = Broker::exists(h, k) ) when [k] ( local r = Broker::exists(h, k) )
{ {
step += 1; step += 1;
print fmt("[%d]", step), k, r; print fmt("[%d]", step), k, r;
@ -40,7 +40,7 @@ function print_exists(k: any)
function print_index_from_value(k: any, i: any) function print_index_from_value(k: any, i: any)
{ {
when ( local r = Broker::get_index_from_value(h, k, i) ) when [k, i] ( local r = Broker::get_index_from_value(h, k, i) )
{ {
step += 1; step += 1;
print fmt("[%d]", step), k, r$status, r$result; print fmt("[%d]", step), k, r$status, r$result;

View file

@ -12,7 +12,7 @@ global h: opaque of Broker::Store;
function print_index(k: any) function print_index(k: any)
{ {
when ( local r = Broker::get(h, k) ) when [k] ( local r = Broker::get(h, k) )
{ {
print k, r$status, r$result; print k, r$status, r$result;
} }

View file

@ -52,7 +52,7 @@ function die()
{ {
local h: addr = 127.0.0.1; local h: addr = 127.0.0.1;
when ( local hname = lookup_addr(h) ) when [h] ( local hname = lookup_addr(h) )
{ {
print "lookup successful"; print "lookup successful";
terminate(); terminate();

View file

@ -43,7 +43,7 @@ event do_another()
if ( ! done ) if ( ! done )
schedule 1sec { set_flag() }; schedule 1sec { set_flag() };
when ( local result = async_func("from do_another()") ) when [local_dummy, anon] ( local result = async_func("from do_another()") )
{ {
print "async_func() return result in do_another()", result; print "async_func() return result in do_another()", result;
print local_dummy("from do_another() when block"); print local_dummy("from do_another() when block");
@ -66,7 +66,7 @@ event zeek_init()
schedule 1sec { set_flag() }; schedule 1sec { set_flag() };
when ( local result = async_func("from zeek_init()") ) when [local_dummy, anon] ( local result = async_func("from zeek_init()") )
{ {
print "async_func() return result in zeek_init()", result; print "async_func() return result in zeek_init()", result;
print local_dummy("from zeek_init() when block"); print local_dummy("from zeek_init() when block");

View file

@ -9,7 +9,7 @@ event zeek_init()
{ {
local h: addr = 127.0.0.1; local h: addr = 127.0.0.1;
when ( local hname = lookup_addr(h) ) when [h] ( local hname = lookup_addr(h) )
{ {
print "lookup successful"; print "lookup successful";
terminate(); terminate();
@ -21,9 +21,9 @@ event zeek_init()
local to = 5sec; local to = 5sec;
# Just checking that timeouts can use arbitrary expressions... # Just checking that timeouts can use arbitrary expressions...
when ( local hname2 = lookup_addr(h) ) {} when [h] ( local hname2 = lookup_addr(h) ) {}
timeout to {} timeout to {}
when ( local hname3 = lookup_addr(h) ) {} when [h] ( local hname3 = lookup_addr(h) ) {}
timeout to + 2sec {} timeout to + 2sec {}
print "done"; print "done";