Fixed crash when memory hard limit is disabled, close #1074

This commit is contained in:
Dylan K. Taylor 2017-06-12 09:32:31 +01:00
parent 433b8369f5
commit 3167817e34
2 changed files with 12 additions and 8 deletions

View File

@ -92,7 +92,7 @@ class MemoryManager{
$hardLimit = ((int) $this->server->getProperty("memory.main-hard-limit", $defaultMemory)); $hardLimit = ((int) $this->server->getProperty("memory.main-hard-limit", $defaultMemory));
if($hardLimit <= 0){ if($hardLimit <= 0){
ini_set("memory_limit", -1); ini_set("memory_limit", '-1');
}else{ }else{
ini_set("memory_limit", $hardLimit . "M"); ini_set("memory_limit", $hardLimit . "M");
} }

View File

@ -1999,9 +1999,11 @@ class Server{
$this->getLogger()->debug("Removing event handlers"); $this->getLogger()->debug("Removing event handlers");
HandlerList::unregisterAll(); HandlerList::unregisterAll();
if($this->scheduler instanceof ServerScheduler){
$this->getLogger()->debug("Stopping all tasks"); $this->getLogger()->debug("Stopping all tasks");
$this->scheduler->cancelAllTasks(); $this->scheduler->cancelAllTasks();
$this->scheduler->mainThreadHeartbeat(PHP_INT_MAX); $this->scheduler->mainThreadHeartbeat(PHP_INT_MAX);
}
$this->getLogger()->debug("Saving properties"); $this->getLogger()->debug("Saving properties");
$this->properties->save(); $this->properties->save();
@ -2010,11 +2012,13 @@ class Server{
$this->console->shutdown(); $this->console->shutdown();
$this->console->notify(); $this->console->notify();
if($this->network instanceof Network){
$this->getLogger()->debug("Stopping network interfaces"); $this->getLogger()->debug("Stopping network interfaces");
foreach($this->network->getInterfaces() as $interface){ foreach($this->network->getInterfaces() as $interface){
$interface->shutdown(); $interface->shutdown();
$this->network->unregisterInterface($interface); $this->network->unregisterInterface($interface);
} }
}
gc_collect_cycles(); gc_collect_cycles();
}catch(\Throwable $e){ }catch(\Throwable $e){