[Bro-Dev] 'for loop' variable modification

Jim Mellander jmellander at lbl.gov
Fri Jan 5 12:19:26 PST 2018


Hi all:

I'm working on an interesting Bro policy, and I want to be able to begin a
'for loop' at some point where it previously left off.

Pseudo-code:

for (foo in bar)
    {
    if (foo == "baz")    break;
    .
    process bar[foo]
    .
    }
.
.
Do other work (not changing bar)
.
.
first_time = T;
for (foo in bar)
    {
    if (first_time)
        {
        first_time = F;
        foo = "baz";
        }
    .
    process bar[foo]
    .
    }

....

If the loop variable can be reassigned in the loop, and the loop continued
from that point, it would facilitate some of the processing I'm doing.  The
above synthetic code could be refactored to avoid the issue, but....

My real-world issue is that I have a large table to process, and want to
amortize the processing of it on the time domain:

A. Process first N items in table
B. Schedule processing of next N items via an event
C. When event triggers, pick up where we left off, and process next N
items, etc.

(There are inefficient ways of processing these that solve some, but not
all issues, such as putting the indices in a vector, then going thru that -
wont go into the problems with that right now)


I haven't checked whether my desired behavior works, but since its not
documented, I wouldn't want to rely on it in any event.

I would be interested in hearing comments or suggestions on this issue.

Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.icsi.berkeley.edu/pipermail/bro-dev/attachments/20180105/b32aa19b/attachment.html 


More information about the bro-dev mailing list