mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 11:57:10 +00:00
NetworkSession: defer destructive cleanup until the next session tick() call
this fixes crashes when kicking players during PlayerJoinEvent and various other events.
This commit is contained in:
parent
6375139d0b
commit
f7d0d16eb3
@ -547,13 +547,18 @@ class NetworkSession{
|
|||||||
$this->disposeHooks->clear();
|
$this->disposeHooks->clear();
|
||||||
$this->setHandler(null);
|
$this->setHandler(null);
|
||||||
$this->connected = false;
|
$this->connected = false;
|
||||||
$this->manager->remove($this);
|
|
||||||
$this->logger->info("Session closed due to $reason");
|
$this->logger->info("Session closed due to $reason");
|
||||||
|
|
||||||
$this->invManager = null; //break cycles - TODO: this really ought to be deferred until it's safe
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs actions after the session has been disconnected. By this point, nothing should be interacting with the
|
||||||
|
* session, so it's safe to destroy any cycles and perform destructive cleanup.
|
||||||
|
*/
|
||||||
|
private function dispose() : void{
|
||||||
|
$this->invManager = null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnects the session, destroying the associated player (if it exists).
|
* Disconnects the session, destroying the associated player (if it exists).
|
||||||
*/
|
*/
|
||||||
@ -1114,6 +1119,11 @@ class NetworkSession{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function tick() : void{
|
public function tick() : void{
|
||||||
|
if(!$this->isConnected()){
|
||||||
|
$this->dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->info === null){
|
if($this->info === null){
|
||||||
if(time() >= $this->connectTime + 10){
|
if(time() >= $this->connectTime + 10){
|
||||||
$this->disconnect("Login timeout");
|
$this->disconnect("Login timeout");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user