Skip to content

Commit

Permalink
Don't generate a matchup in php but wait for one to become available
Browse files Browse the repository at this point in the history
  • Loading branch information
Janzert committed Dec 21, 2011
1 parent 04b482d commit fcf36ac
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions website/api_get_task.php
Expand Up @@ -25,6 +25,8 @@
}

// look for match
$start_time = time();
$check_time = $start_time;
$matchup_tries = 0;
$match_result = null;
$match_row = null;
Expand All @@ -49,12 +51,19 @@
continue;
}
} else {
$mysqli = new MySQLI($db_host, $db_username, $db_password, $db_name);
$mysqli->multi_query('call generate_matchup;');
while ($mysqli->more_results() && $mysqli->next_result());
$mysqli->close();
sleep(rand(1, 5));
if (time() - $check_time > 30) {
$check_time = time();
api_log(sprintf(
"Worker %d still waiting for a matchup after %d seconds",
$worker["worker_id"], $check_time - $start_time));
}
}
}
if (time() - $start_time > 20) {
api_log(sprintf("Worker %d got a match after %d seconds",
$worker["worker_id"], time() - $start_time));
}

if ($match_row) {
$json = array( "task" => "game",
Expand Down

0 comments on commit fcf36ac

Please sign in to comment.