From: Matteo Nastasi Date: Sun, 22 May 2011 15:52:35 +0000 (+0200) Subject: webservers_exceeded() and check_webservers() functions added to change behaviour... X-Git-Tag: 3.5.6~7 X-Git-Url: https://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=04de0e58bd8e0d0de4e317d79611dfdb71180d22;p=brisk.git webservers_exceeded() and check_webservers() functions added to change behaviour of page_streaming --- diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 8663ca2..67854cf 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -284,6 +284,39 @@ Copyright 2006-2009 Matteo Nasta
version '.$G_brisk_version.'

Copyright 2006-2009
Matteo Nastasi (aka mop)

'); +function webservers_exceeded() +{ + return(file_exists(PROXY_PATH."/webservers_exceded.flag")); +} + +function check_webservers() +{ + GLOBAL $G_webserver_max; + + $ct = 0; + + $dh = opendir('/proc'); + while (($file = readdir($dh)) !== false) { + if (preg_match('/[0-9]+/', $file)) { + $cmdline = explode("\0", file_get_contents('/proc/'.$file.'/cmdline')); + // echo "xxx".$cmdline[0].$n; + if (strstr('/usr/sbin/apache2', $cmdline[0]) != FALSE) { + // echo "yyy".$cmdline[0].$n; + $ct++; + } + } + } + closedir($dh); + + if ($ct >= $G_webserver_max) { + touch(PROXY_PATH."/webservers_exceded.flag"); + } + else { + unlink(PROXY_PATH."/webservers_exceded.flag"); + } + return ($ct); +} + $escinp_from = array( "\"" ); $escinp_to = array( """ ); @@ -1084,6 +1117,7 @@ class Room { return ($ismod); } + check_webservers(); // FIXME BRISK4: include for each kind of table require_once("${G_base}briskin5/Obj/briskin5.phh"); diff --git a/web/briskin5/index_rd.php b/web/briskin5/index_rd.php index 0e273a1..75081a7 100644 --- a/web/briskin5/index_rd.php +++ b/web/briskin5/index_rd.php @@ -328,7 +328,7 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su step */ -$is_page_streaming = (stristr($HTTP_USER_AGENT, "MSIE") || stristr($HTTP_USER_AGENT, "CHROME") ? TRUE : FALSE); +$is_page_streaming = (webservers_exceeded() || stristr($HTTP_USER_AGENT, "MSIE") || stristr($HTTP_USER_AGENT, "CHROME") ? TRUE : FALSE); header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past diff --git a/web/index_rd.php b/web/index_rd.php index 6c8c5db..2283ec5 100644 --- a/web/index_rd.php +++ b/web/index_rd.php @@ -380,7 +380,7 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su step */ -$is_page_streaming = (stristr($HTTP_USER_AGENT, "MSIE") || stristr($HTTP_USER_AGENT, "CHROME") ? TRUE : FALSE); +$is_page_streaming = (webservers_exceeded() || stristr($HTTP_USER_AGENT, "MSIE") || stristr($HTTP_USER_AGENT, "CHROME") ? TRUE : FALSE); header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past