Eggheads: utimers acting weird

NeoN neon at pandora.be
Thu Feb 12 21:13:37 CST 2004


While writing a script, I stumbled upon some problems with utimers.  I
have reduced this to the code pasted below.  The dcc binds are just
included for easier testing.

After the second execution of test_caller, there are 3 utimers running,
while there should only be 2.  In the second execution [llength
[utimers]] return 0, but there are utimers running.  The check for a
running utimer fails of course, and a new utimer is started.

In the third execution however [llength [utimers]] returns 1, so now
test_callee "sees" one of the utimers.

Calling test_caller or test_callee directly (eg: .tcl test_callee)
does give the expected behaviour.

I have tested this on eggdrop v1.6.15 with Tcl v8.3.3

Am I overlooking something or is this a bug?


The test code:

proc test_callee {} {
    putlog "Before: [llength [utimers]]"
    if {[lsearch -regexp [utimers] "test_callee"] == -1} {
        putlog "Started new timer"
        utimer 30 test_callee
    }
    putlog "After: [llength [utimers]]"
}

proc test_caller {} {
    putlog "Before call: [llength [utimers]]"
    test_callee
    putlog "After call: [llength [utimers]]"
    utimer 25 "test_caller"            
}

bind dcc n test test
bind dcc n ut ut
bind dcc n kt kt

# start
proc test {handle idx text} {
    utimer 1 test_caller
}

# show utimers
proc ut {handle idx text} {
    putdcc $idx "timers: [llength [utimers]]"
    foreach t [utimers] {
        putdcc $idx "$t"   
    }
}

# kill utimers
proc kt {handle idx text} {
    foreach t [utimers] {
        if {[string match "test_*" [lindex $t 1]]} {
            killutimer [lindex $t 2]
        }
    }
}


-- 
NeoN




More information about the Eggheads mailing list