Forum Discussion

Adam_24063's avatar
Adam_24063
Icon for Nimbostratus rankNimbostratus
Apr 15, 2007

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

3 Replies

  • Thanks for the reply.

     

    Sorry I asked questions already answered was apparently having some trouble with the Search form.

     

     

    ( When i originally searched the forums before posting I didn't realize that (in Firefox anyway) you have to click the "GO" link next to the search filed rather than just hitting return. If you just hit return, the page submits but you get no results. The message actually SAYS that you haven't submitted search terms, but I just didn't process what had happened.)

     

  • Yeah, we are working on that issue. Basically entering in the text field is defaulting to the site wide search field above and not the custom forum search that the forum search box is attached to.

     

     

    In the mean time, just type your query, hit tab, then enter. That should work for you.

     

     

    -Joe