Forum Discussion
smp_86112
Cirrostratus
May 04, 2010v10 - local vs. global vars
Trying to wrap my mind around how this variable scope works. I have a simple iRule I'm testing with:
when HTTP_REQUEST {
global client_local [TCP::local_port clientside]
if...
hoolio
Cirrostratus
May 04, 2010I haven't used the TCL 'global' command before. Per the TCL wiki page on the command, I don't think it could be used in current versions of iRules as there is no support for procs in iRules as of now:
http://www.tcl.tk/man/tcl8.4/TclCmd/global.htm
This command has no effect unless executed in the context of a proc body.
If you did want to declare a global variable, you could use 'set ::my_global_var' and then reference it using $::my_global_var. However, I don't think you want to use a global variable in the scenario you've described. If you want to set a variable for one client connection and access the variable later in the same iRule or in another iRule on the same VIP, you could use a local variable. Using a global variable means that all client connections will reference the same variable. If one HTTPS connection was established and then another client established an HTTP connection, the HTTP connection would set the global variable to "http" for itself and any prior requests that were still established.
See this post for some additional info:
http://devcentral.f5.com/Default.aspx?tabid=53&view=topic&postid=85746&ptarget=85747
Aaron
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects