ChunkCache: fixed corner case in cache restart on AsyncTask error

the cache may have been destroyed since the task inception, leading to an exception being thrown.
This commit is contained in:
Dylan K. Taylor 2021-12-27 18:11:55 +00:00
parent 8943d8a2a7
commit 4aab0565c0
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -128,11 +128,13 @@ class ChunkCache implements ChunkListener{
$chunk, $chunk,
$this->caches[$chunkHash], $this->caches[$chunkHash],
$this->compressor, $this->compressor,
function() use ($chunkX, $chunkZ) : void{ function() use ($chunkHash, $chunkX, $chunkZ) : void{
$this->world->getLogger()->error("Failed preparing chunk $chunkX $chunkZ, retrying"); $this->world->getLogger()->error("Failed preparing chunk $chunkX $chunkZ, retrying");
if(isset($this->caches[$chunkHash])){
$this->restartPendingRequest($chunkX, $chunkZ); $this->restartPendingRequest($chunkX, $chunkZ);
} }
}
) )
); );