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,10 +128,12 @@ class ChunkCache implements ChunkListener{
$chunk,
$this->caches[$chunkHash],
$this->compressor,
function() use ($chunkX, $chunkZ) : void{
function() use ($chunkHash, $chunkX, $chunkZ) : void{
$this->world->getLogger()->error("Failed preparing chunk $chunkX $chunkZ, retrying");
$this->restartPendingRequest($chunkX, $chunkZ);
if(isset($this->caches[$chunkHash])){
$this->restartPendingRequest($chunkX, $chunkZ);
}
}
)
);