mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-08-21 02:41:17 +00:00
Removed locks from MainLogger
This commit is contained in:
parent
441b47e744
commit
49370c21d1
@ -152,16 +152,15 @@ class MainLogger extends \Thread implements Logger{
|
||||
if(!is_resource($this->logResource)){
|
||||
throw new \RuntimeException("Couldn't open log file");
|
||||
}
|
||||
flock($this->logResource, LOCK_EX);
|
||||
|
||||
while($this->shutdown === false){
|
||||
if(strlen($this->logStream) >= 4096){
|
||||
$this->synchronized(function (){
|
||||
$chunks = strlen($this->logStream) >> 12;
|
||||
$chunk = substr($this->logStream, 0, $chunks << 12);
|
||||
$this->logStream = substr($this->logStream, $chunks << 12);
|
||||
fwrite($this->logResource, $chunk);
|
||||
});
|
||||
$this->lock();
|
||||
$chunks = strlen($this->logStream) >> 12;
|
||||
$chunk = substr($this->logStream, 0, $chunks << 12);
|
||||
$this->logStream = substr($this->logStream, $chunks << 12);
|
||||
$this->unlock();
|
||||
fwrite($this->logResource, $chunk);
|
||||
}else{
|
||||
usleep(250000); //sleep for 0.25 seconds
|
||||
}
|
||||
@ -170,7 +169,6 @@ class MainLogger extends \Thread implements Logger{
|
||||
fwrite($this->logResource, $this->logStream);
|
||||
}
|
||||
|
||||
flock($this->logResource, LOCK_UN);
|
||||
fclose($this->logResource);
|
||||
}
|
||||
}
|
@ -152,16 +152,15 @@ class MainLogger extends \Thread implements Logger{
|
||||
if(!is_resource($this->logResource)){
|
||||
throw new \RuntimeException("Couldn't open log file");
|
||||
}
|
||||
flock($this->logResource, LOCK_EX);
|
||||
|
||||
while($this->shutdown === false){
|
||||
if(strlen($this->logStream) >= 4096){
|
||||
$this->synchronized(function (){
|
||||
$chunks = strlen($this->logStream) >> 12;
|
||||
$chunk = substr($this->logStream, 0, $chunks << 12);
|
||||
$this->logStream = substr($this->logStream, $chunks << 12);
|
||||
fwrite($this->logResource, $chunk);
|
||||
});
|
||||
$this->lock();
|
||||
$chunks = strlen($this->logStream) >> 12;
|
||||
$chunk = substr($this->logStream, 0, $chunks << 12);
|
||||
$this->logStream = substr($this->logStream, $chunks << 12);
|
||||
$this->unlock();
|
||||
fwrite($this->logResource, $chunk);
|
||||
}else{
|
||||
usleep(250000); //sleep for 0.25 seconds
|
||||
}
|
||||
@ -170,7 +169,6 @@ class MainLogger extends \Thread implements Logger{
|
||||
fwrite($this->logResource, $this->logStream);
|
||||
}
|
||||
|
||||
flock($this->logResource, LOCK_UN);
|
||||
fclose($this->logResource);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user