Explicitly release server.lock file when shutdown the server. (#3619)

Previously, this relied on PHP itself to release locks during the resource destructor phase during process exit, but sometimes it doesn't for god knows what reason. This change makes the lock file get explicitly released before the process dies.
This commit is contained in:
Matt 2020-06-26 12:41:39 +02:00 committed by GitHub
parent d343187e58
commit df76c02e7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -289,6 +289,14 @@ namespace pocketmine {
echo Terminal::$FORMAT_RESET . PHP_EOL;
if(!flock(\pocketmine\LOCK_FILE, LOCK_UN)){
critical_error("Failed to release the server.lock file.");
}
if(!fclose(\pocketmine\LOCK_FILE)){
critical_error("Could not close server.lock resource.");
}
exit($exitCode);
}

View File

@ -82,7 +82,7 @@ parameters:
-
message: "#^Parameter \\#1 \\$fp of function flock expects resource, resource\\|false given\\.$#"
count: 3
count: 4
path: ../../../src/pocketmine/PocketMine.php
-
@ -105,6 +105,11 @@ parameters:
count: 1
path: ../../../src/pocketmine/PocketMine.php
-
message: "#^Parameter \\#1 \\$fp of function fclose expects resource, resource\\|false given\\.$#"
count: 1
path: ../../../src/pocketmine/PocketMine.php
-
message: "#^Parameter \\#1 \\$buffer of method pocketmine\\\\nbt\\\\NBTStream\\:\\:readCompressed\\(\\) expects string, string\\|false given\\.$#"
count: 1