Forum Discussion

AndrewO_4840's avatar
AndrewO_4840
Icon for Nimbostratus rankNimbostratus
Feb 12, 2009

How can this fail?

I'm using a variation of the request rate limiting iRule ( http://devcentral.f5.com/wiki/default.aspx/iRules/HTTPRequestThrottle.html ) - it's essentially the same without the whitelist or blacklist features.

The rule breaks on the line:

  set elapsed_time [expr {$curr_time - $start_time}}

and throws the error:

> - can't use empty string as operand of "-" while executing "expr {$curr_time - $start_time}"

This rule contains the lines:

    set curr_time [clock seconds] 

and:

set request_count [session lookup uie $reqkey]   
 if {$request_count > 0} { 
   set start_time [session lookup uie $timekey] 
   ...

Since $curr_time is defined, and $start_time is defined if the session lookup returns some value, how can either of them be 0 and cause my iRule to fail?

2 Replies

  • It looks like the interpreter thinks you're dealing with a literal empty string, not a zero (or other number). This is from a normal TCL command line, not a BigIP, but it's pretty easy to replicate:

     

     

     
     % set one [clock seconds] 
     1234571258 
      
     % set two "" 
     % expr { $one - $two } 
     can't use empty string as operand of "-" 
     % 
     % set two 0 
     0 
     % expr { $one - $two } 
     1234571258 
     % 
      
     

     

     

    So this hints that you may need to look back at the code and make sure that $start_time is correctly set to something other than an empty string.

     

     

    HTH,

     

    -Matt