Index: openacs-4/packages/xotcl-request-monitor/tcl/throttle_mod-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-request-monitor/tcl/throttle_mod-procs.tcl,v diff -u -N -r1.67.2.37 -r1.67.2.38 --- openacs-4/packages/xotcl-request-monitor/tcl/throttle_mod-procs.tcl 25 Jan 2021 16:56:52 -0000 1.67.2.37 +++ openacs-4/packages/xotcl-request-monitor/tcl/throttle_mod-procs.tcl 26 Jan 2021 21:00:12 -0000 1.67.2.38 @@ -52,7 +52,7 @@ package_parameter time-window -default 10 package_parameter trend-elements -default 48 package_parameter map-slow-pool-duration -default [expr {12*60*60*1000}] ;# 12h - #package_parameter map-slow-pool-duration -default [expr {60*1000}] + #package_parameter map-slow-pool-duration -default [expr {20*1000}] ;# 20s # # When updates happen on @@ -1432,6 +1432,23 @@ dump write } + ad_proc -private ::unmap_pool { + {-pool slow} + {-ms} + method + url + } { + Function within throttle monitor thread for registering pool + unmapping reuests after a specified time. This function has to run + in this thread to be able to use "::after". + } { + if {![info exists ms]} { + set ms [::map-slow-pool-duration] + } + after $ms [list ::xo::unmap_pool -pool $pool $method $url] + ns_log notice "slow request: mapping of '$url' moved to '$pool' connection pool will be canceled in $ms ms" + } + Object create dump dump set file ${logdir}/throttle-data.dump dump proc read {} { @@ -1856,7 +1873,7 @@ } namespace eval ::xo { - + ad_proc -private ::xo::unmap_pool { {-pool slow} method @@ -1890,11 +1907,13 @@ ns_server -pool $pool map -noinherit [list $method $url] ns_log notice "slow request: '$url' moved to '$pool' connection pool" - if {[info commands ::map-slow-pool-duration] ne ""} { - set ms [::map-slow-pool-duration] - after $ms [list ::xo::unmap_pool -pool $pool $method $url] - ns_log notice "slow request: mapping of '$url' moved to '$pool' connection pool will be canceled in $ms ms" - } + # + # In case, we are executing in the throttle monitor thread, call + # the register unmap function directly, otherwise instruct the + # monitor thread to do so. + # + set prefix [expr {[ns_thread name] eq "::throttle" ? {} : {::throttle do}}] + {*}$prefix ::unmap_pool -pool $pool $method $url } }