mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-04 17:20:02 +00:00
Remove level locks, possible fix for #2046
This commit is contained in:
parent
6fb7170556
commit
8c627bd0af
@ -45,7 +45,6 @@ class RegionLoader extends \pocketmine\level\format\mcregion\RegionLoader{
|
|||||||
$this->filePath = $this->levelProvider->getPath() . "region/r.$regionX.$regionZ.mca";
|
$this->filePath = $this->levelProvider->getPath() . "region/r.$regionX.$regionZ.mca";
|
||||||
touch($this->filePath);
|
touch($this->filePath);
|
||||||
$this->filePointer = fopen($this->filePath, "r+b");
|
$this->filePointer = fopen($this->filePath, "r+b");
|
||||||
flock($this->filePointer, LOCK_EX);
|
|
||||||
stream_set_read_buffer($this->filePointer, 1024 * 16); //16KB
|
stream_set_read_buffer($this->filePointer, 1024 * 16); //16KB
|
||||||
stream_set_write_buffer($this->filePointer, 1024 * 16); //16KB
|
stream_set_write_buffer($this->filePointer, 1024 * 16); //16KB
|
||||||
if(!file_exists($this->filePath)){
|
if(!file_exists($this->filePath)){
|
||||||
|
@ -191,7 +191,7 @@ class McRegion extends BaseLevelProvider{
|
|||||||
public function unloadChunk($x, $z, $safe = true){
|
public function unloadChunk($x, $z, $safe = true){
|
||||||
$chunk = $this->getChunk($x, $z, false);
|
$chunk = $this->getChunk($x, $z, false);
|
||||||
if($chunk instanceof FullChunk){
|
if($chunk instanceof FullChunk){
|
||||||
if($safe === true and $this->isChunkLoaded($x, $z)){
|
if($safe === true){
|
||||||
foreach($chunk->getEntities() as $entity){
|
foreach($chunk->getEntities() as $entity){
|
||||||
if($entity instanceof Player){
|
if($entity instanceof Player){
|
||||||
return false;
|
return false;
|
||||||
|
@ -55,7 +55,6 @@ class RegionLoader{
|
|||||||
$this->filePath = $this->levelProvider->getPath() . "region/r.$regionX.$regionZ.mcr";
|
$this->filePath = $this->levelProvider->getPath() . "region/r.$regionX.$regionZ.mcr";
|
||||||
touch($this->filePath);
|
touch($this->filePath);
|
||||||
$this->filePointer = fopen($this->filePath, "r+b");
|
$this->filePointer = fopen($this->filePath, "r+b");
|
||||||
flock($this->filePointer, LOCK_EX);
|
|
||||||
stream_set_read_buffer($this->filePointer, 1024 * 16); //16KB
|
stream_set_read_buffer($this->filePointer, 1024 * 16); //16KB
|
||||||
stream_set_write_buffer($this->filePointer, 1024 * 16); //16KB
|
stream_set_write_buffer($this->filePointer, 1024 * 16); //16KB
|
||||||
if(!file_exists($this->filePath)){
|
if(!file_exists($this->filePath)){
|
||||||
@ -67,9 +66,7 @@ class RegionLoader{
|
|||||||
|
|
||||||
public function __destruct(){
|
public function __destruct(){
|
||||||
if(is_resource($this->filePointer)){
|
if(is_resource($this->filePointer)){
|
||||||
$this->cleanGarbage();
|
|
||||||
$this->writeLocationTable();
|
$this->writeLocationTable();
|
||||||
flock($this->filePointer, LOCK_UN);
|
|
||||||
fclose($this->filePointer);
|
fclose($this->filePointer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -199,7 +196,6 @@ class RegionLoader{
|
|||||||
|
|
||||||
public function close(){
|
public function close(){
|
||||||
$this->writeLocationTable();
|
$this->writeLocationTable();
|
||||||
flock($this->filePointer, LOCK_UN);
|
|
||||||
fclose($this->filePointer);
|
fclose($this->filePointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user