Pre-check reachability to avoid long locks
This commit is contained in:
@@ -28,6 +28,20 @@ if ($error_reporting) {
|
||||
ini_set('display_errors', 1);
|
||||
}
|
||||
|
||||
$reachable = false;
|
||||
if (isset($_GET["new"])) {
|
||||
require "enet_probe.php";
|
||||
$host = $_SERVER['REMOTE_ADDR'];
|
||||
if (!empty($_GET["host"])) {
|
||||
$host = $_GET["host"];
|
||||
}
|
||||
$port = 50403;
|
||||
if (!empty($_GET["port"]) && is_numeric($_GET["port"])) {
|
||||
$port = intval($_GET["port"]);
|
||||
}
|
||||
$reachable = enet_probe($host, $port);
|
||||
}
|
||||
|
||||
$dirname = dirname($state_file);
|
||||
if (!is_dir($dirname)) {
|
||||
mkdir($dirname, 0777, true);
|
||||
@@ -66,16 +80,6 @@ if (isset($_GET["list"])) {
|
||||
echo json_encode(["lobbies" => $list]);
|
||||
}
|
||||
elseif (isset($_GET["new"])) {
|
||||
require "enet_probe.php";
|
||||
$host = $_SERVER['REMOTE_ADDR'];
|
||||
if (!empty($_GET["host"])) {
|
||||
$host = $_GET["host"];
|
||||
}
|
||||
$port = 50403;
|
||||
if (!empty($_GET["port"]) && is_numeric($_GET["port"])) {
|
||||
$port = intval($_GET["port"]);
|
||||
}
|
||||
$reachable = enet_probe($host, $port);
|
||||
header("Content-Type: application/json");
|
||||
if ($reachable) {
|
||||
$id = generate_uuid_v4();
|
||||
|
||||
Reference in New Issue
Block a user