Commit: 513be2a6d828e696c80271a52c58e2748ffed211 Author: Ferenc Kovacs <[email protected]> Fri, 1 Feb 2013 13:06:32 +0100 Parents: 8a6bfe8456f73c8dc1801356c3adeeadada917c2 Branches: master
Link: http://git.php.net/?p=web/master.git;a=commitdiff;h=513be2a6d828e696c80271a52c58e2748ffed211 Log: the header check in host_has_error won't work for the spoofed headers so we should check the response body that it matches the expected format of mirror-info Changed paths: M scripts/mirror-test Diff: diff --git a/scripts/mirror-test b/scripts/mirror-test index 4fc5a51..074c668 100755 --- a/scripts/mirror-test +++ b/scripts/mirror-test @@ -165,17 +165,31 @@ foreach ($hosts as $index => $host) { // if the mirror is used for the load balancing check that it can serve the mirror-info for cc.php.net also $lb_data = $lb_problem = ''; - if ($host['load_balanced'] && host_has_error($host['hostname'], $filename, $lb_data, $lb_problem, $host['load_balanced'].'.php.net')) { - // remove from rotation - $query = "UPDATE mirrors SET load_balanced = '' WHERE hostname = '" . $host['hostname'] . "'"; - $result = mysql_query($query) or die("unable to update the database: $query: " . mysql_error()); - // send an email to systems, when we are stable enough, we should change this to php-mirrors@ - mail( - "[email protected]", - "Round robin for {$host['hostname']} is deactivated", - "The following error occured when testing {$host['hostname']} for serving traffic for {$host['load_balanced']}.php.net: \n{$lb_problem}", - "From: [email protected]" - ); + if ($host['load_balanced']) { + $lb_error = host_has_error($host['hostname'], $filename, $lb_data, $lb_problem, $host['load_balanced'].'.php.net'); + if (!$lb_error) { + // Explode information row by delimiter + $lb_info = explode("|", trim($lb_data)); + + // Invalid data received, skip mirror site + if (count($lb_info) < 8) { + $lb_error = TRUE; + $lb_problem = "Invalid data received from {$filename}."; + } + } + + if ($lb_error) { + $lb_problem = "The following error occured when testing {$host['hostname']} for serving traffic for {$host['load_balanced']}.php.net:\n".$lb_problem; + $query = "UPDATE mirrors SET load_balanced = '' WHERE hostname = '" . $host['hostname'] . "'"; + $result = mysql_query($query) or die("unable to update the database: $query: " . mysql_error()); + // send an email to systems, when we are stable enough, we should change this to php-mirrors@ + mail( + "[email protected]", + "Round robin for {$host['hostname']} is deactivated", + $lb_problem, + "From: [email protected]" + ); + } } // Explode information row by delimiter -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
