Not sure if this is a bug or I am using it wrong. Consider the following
snippet. I start it using `sudo ./bin/bro -i eth0 module_test`.
*File: share/bro/site/module_test/raise.bro*
module module_test;
# Remove the module to make the example work
# OR define the event handler within another module
export {
global my_event: event(a: int, s: string);
}
event raise_my_event() {
local a: int = 42;
local s: string = "Hello World";
print(fmt("Raising event with a=%d and s=%s", a, s));
event my_event(a, s);
}
#module module2;
event my_event(a: int, s: string) {
print(fmt("Received event with a=%d and s=%s", a, s));
}
event bro_init() {
local w: interval = 10sec;
print(fmt("Starting example, waiting for %s", w));
#"raise_my_event()" is executed immediately
schedule w {raise_my_event()};
}
# Problem 1: Event Handling within module
The handler for "my_event" is not invoked as long as it is defined
within the same module "module_test".
- Workaround a): Do not use modules at all
- Workaround b): Define the handler in a different module
But why should not it be allowed to raise and handle events within the
same module?
# Problem 2: Direct execution of scheduled events
At least within this example, I expected the "raise_my_event" to be
invoked after 10 seconds. However, it is done immediately. Am I using
the schedule wrong?
I am running the current master (0f550806252b46d3e13be24cd2ab4bb8a63bf49b).
Any help appreciated. Best,
Steffen.