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