ad_return_if_another_copy_is_running { max_simultaneous_copies "1" } { call_adp_break_p "0" }What it does:
Returns a page to the user about how this server is busy if another copy of the same script is running. Then terminates execution of the thread. Useful for expensive pages that do sequential searches through Oracle tables, etc. You don't want to tie up all of your Oracle handles and deny service to everyone else. The call_adp_break_p argument is essential if you are calling this from an ADP page and want to avoid the performance hit of continuing to parse and run.Defined in: /web/philip/packages/acs-core/defs-procs.tcl
Source code:
# first let's figure out how many are running and queued set this_connection_url [ns_conn url] set n_matches 0 foreach connection [ns_server active] { set query_connection_url [lindex $connection 4] if { $query_connection_url == $this_connection_url } { # we got a match (we'll always get at least one # since we should match ourselves) incr n_matches } } if { $n_matches > $max_simultaneous_copies } { ad_return_warning "Too many copies" "This is an expensive page for our server, which is already running the same program on behalf of some other users. Please try again at a less busy hour." # blow out of the caller as well if $call_adp_break_p { # we were called from an ADP page; we have to abort processing ns_adp_break } return -code return } # we're okay return 1