Forum Discussion

danielc's avatar
danielc
Icon for Cirrus rankCirrus
Jul 07, 2022
Solved

A simple way to unset all variable during Client_CLOSED ?

Hello,

I have a CLOSED_CONNECTION irule at the end of the VS to unset all variables:

 
when CLIENT_CLOSED {
  TCP::close
  
  if { [info exists demo1] } {
    unset demo1
  }
  if { [info exists demo2] } {
    unset demo2
  }
 
,,,,,
 
 }
However If I have 1000 variable sauy demo1 to demo1000, then I will need to if 1000 times here to unset them, Is there any simple way can unset all variables during CLIENT_CLOSED ? Thanks
  • Variables are scoped to the connection. After its closed they no longer exist. The only time this is not the case when you create global variables via rule_init. So there is no need to delete these.

3 Replies

  • Variables are scoped to the connection. After its closed they no longer exist. The only time this is not the case when you create global variables via rule_init. So there is no need to delete these.

    • danielc's avatar
      danielc
      Icon for Cirrus rankCirrus

      Hello Kevin,

      Thanks for the answer. Just want to confirm , what you said also apply to " TCP::close " , right?

      • TCP::close is triggered at the close of the connection. Right after the processing of any iRule events related to that connection, the variables should no longer exist. A connection is a TCP session defined by quatuple of source-ip:source-port and destination-ip:destination-port.