iRule with table apparently leaking memory
I did find SOL12245, which details a known memory leak in the table keys -subtable command, which we use. However, it specifically states that it doesn't apply to the command when the -count option is used, which is the only way that we use it. I can't see any other reason for the memory leak, unless the expiration only applies to keys, but the subtables never expire?
TIA for any help:
when RULE_INIT {
set ::pdfappmaxRate 20 ;set later per user from class
set static::pdfappwindowSecs 300 ;global
}
when HTTP_REQUEST {
if { [HTTP::method] eq "GET" } {
Check to make sure the user is not in a redirect loop because of not accepting cookies
if { (([HTTP::uri] contains "?tag=1?tag=1") or ([HTTP::uri] contains "&tag=1&tag=1")) } {
HTTP::redirect "http://ieeepdfapp.site.com/pdfapp/cookiedetectresponse.jsp"
}
if { (([HTTP::uri] contains "stamp.jsp") or ([HTTP::uri] contains ".pdf")) and not ([HTTP::header exists Range ]) and ([HTTP::cookie exists ERIGHTS])} {
log local0. "pdfapp PDF Initial download detected."
Extract clients IP address
set client_ip [IP::remote_addr]
set pdfapp_session [HTTP::cookie ERIGHTS]
set mypdfappMaxRate $::pdfappmaxRate
set pdfnum [table incr "pdfapp:$pdfapp_session"]
set orig_ip [table lookup -subtable session_map $pdfapp_session]
log local0. "Session ID $pdfapp_session should have IP [table lookup -subtable session_map $pdfapp_session]"
log local0. "Client actually has IP $client_ip"
table lifetime pdfapp:$pdfapp_session 3600
table timeout pdfapp:$pdfapp_session 3600
log local0. "Client $client_ip has $pdfnum total hits"
set tbl "countpdf:$pdfapp_session"
table set -subtable $tbl $pdfnum "ignored" indef $static::pdfappwindowSecs
log local0. "Client $pdfapp_session has: [table keys -subtable $tbl -count] pdf downloads in the past $static::pdfappwindowSecs seconds"
if { [table keys -subtable $tbl -count] > $mypdfappMaxRate } {
log local0. "PDF Abuse - User $client_ip, Session $pdfapp_session"
HTTP::respond 200 content {"Slow Down!"
}
return
}
}
}
}