Forum Discussion

xiangyang_zhang's avatar
xiangyang_zhang
Icon for Nimbostratus rankNimbostratus
Apr 21, 2006

Read&Write problem

With the irule below, can read-write problem happen ?

 

rule tls_flag {

 

when HTTP_REQUEST {

 

set tlsflg 0

 

if {[HTTP::method] equals "CONNECT"}{

 

set tlsflg 1

 

}

 

 

}

 

when HTTP_REQUEST_SEND {

 

if { $tlsreq equals 1 } {

 

HTTP::disable

 

}

 

}

 

}

 

 

Put it with an example

 

 

1. The instance 1, a HTTP request, invoke HTTP_REQUEST, so the tlsflg will be set as 0.

 

2. The instance 2, a HTTPS request, invokes HTTP_REQUEST, then tlsflg is set as 1.

 

3. Instance 1 going to invoke HTTP_REQUEST_SEND, at this point, what value is tlsflg, 0 or 1 ?

 

 

Thanks for any information !

2 Replies

  • Variables are shared within the same connection. If you want to use them across sessions, you'll have to reference them in the global namespace.

    when HTTP_REQUEST {
      set local_var "some value"
      set ::global_var "some other value"
      log local0. "The local value is $local_var"
      log local0. "The global value is $::global_var"
    }

    So, the value in the HTTP_REQUeST_SEND event will be that of the associated HTTP_REQUEST event for that connection.

    Be careful about using lots of global variables as they remain resident in memory until the configuration is reloaded.

    -Joe
  • Many thanks, Joe ! Your answer is always helpful and precise !

     

     

    Just now I did the statistics for the hit of if-statement

     

     

    Under 600TPS and at the interval of 5 minutes, the hit number on

     

    if {[HTTP::method] equals "CONNECT"}{

     

    set tlsflg 1

     

    }

     

     

    is about 5% higher than on

     

     

    if { $tlsreq equals 1 } {

     

    HTTP::disable

     

    }

     

     

    Under lighter load, the numbers of hit are identical.

     

     

    It seems the local variable cannot keep persistent for one connection when load is higher.