cvs: phpweb /include loadavg.inc

From: Date: Thu, 22 May 2003 23:00:08 +0000
Subject: cvs: phpweb /include loadavg.inc
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-17913@lists.php.net to get a copy of this message
wez Thu May 22 19:00:08 2003 EDT Modified files: /phpweb/include loadavg.inc Log: When multiple mirrors are search capable, randomly pick one. Index: phpweb/include/loadavg.inc diff -u phpweb/include/loadavg.inc:1.3 phpweb/include/loadavg.inc:1.4 --- phpweb/include/loadavg.inc:1.3 Thu May 22 17:40:04 2003 +++ phpweb/include/loadavg.inc Thu May 22 19:00:08 2003 @@ -13,16 +13,26 @@ $l = getloadavg(); header("X-PHP-Load: " . implode(", ", $l)); - /* offload them to their favourite mirror */ + $mirrors = array(); + + /* find potential mirrors */ foreach ($MIRRORS as $murl => $mirror) { if ($murl != 'http://www.php.net' && mirror_country($murl) == $COUNTRY && mirror_status($murl) == MIRROR_OK && $mirror[5] /* searchable */) { - header("Location: $murl" . substr($_SERVER['REQUEST_URI'], 1)); - exit; + + $mirrors[] = $murl; } } + + /* randomly pick one of the mirrors in their country */ + if (count($mirrors) > 0) { + $murl = $mirrors[array_rand($mirrors)]; + header("Location: $murl" . substr($_SERVER['REQUEST_URI'], 1)); + exit; + } + /* no searchable mirror was found, allow the request through if the load * isn't really really high */ if ($l[0] > 20) {

« previous php.mirrors (#17913) next »