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));
if($hardLimit <= 0){
ini_set("memory_limit", -1);
ini_set("memory_limit", '-1');
}else{
ini_set("memory_limit", $hardLimit . "M");
}

View File

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