Adam_24063
Apr 15, 2007Nimbostratus
synchronization / concurrent access to global variables
Hello again,
I haven't seen any mention anywhere of concurrent access or threading or anything like that. Is this something one needs to think about ?
Are event handlers globally serialized or do they run in parallel ?
Looking at the example rule having to do with limiting connections per client IP address:
when CLIENT_CLOSED {
if { [info exists ::active_clients($client_ip)] } {
incr ::active_clients($client_ip) -1
if { $::active_clients($client_ip) <= 0 } {
unset ::active_clients($client_ip)
}
}
}
I assume that "incr" is atomic (is it ?) but is this check for 0 and the subsequent unset safe ?
if { $::active_clients($client_ip) <= 0 } {
unset ::active_clients($client_ip)
}
i.e. can it be that the value has been incremented by another connection between the time it is checked and the time it is unset?
I assume this would have come up before if it was really an issue since people would have run into it, but I'd like to verify anyway.
thanks,
radu