mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 20:49:43 +00:00
fixed always running main thread by creating sigsegv
This commit is contained in:
parent
eaf97deefe
commit
c07c5e5abd
1 changed files with 9 additions and 9 deletions
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class ConsoleAPI{
|
class ConsoleAPI{
|
||||||
|
private static $loop; //why no Thread::kill in pthreads3
|
||||||
private $loop, $server, $event, $help, $cmds, $alias;
|
private $server, $event, $help, $cmds, $alias;
|
||||||
public $last;
|
public $last;
|
||||||
function __construct(){
|
function __construct(){
|
||||||
$this->help = [];
|
$this->help = [];
|
||||||
|
|
@ -15,7 +15,7 @@ class ConsoleAPI{
|
||||||
public function init(){
|
public function init(){
|
||||||
$this->server->schedule(2, [$this, "handle"], [], true);
|
$this->server->schedule(2, [$this, "handle"], [], true);
|
||||||
if(!defined("NO_THREADS")){
|
if(!defined("NO_THREADS")){
|
||||||
$this->loop = new ConsoleLoop();
|
self::$loop = new ConsoleLoop();
|
||||||
}
|
}
|
||||||
$this->register("help", "[page|command name]", [$this, "defaultCommands"]);
|
$this->register("help", "[page|command name]", [$this, "defaultCommands"]);
|
||||||
$this->register("status", "", [$this, "defaultCommands"]);
|
$this->register("status", "", [$this, "defaultCommands"]);
|
||||||
|
|
@ -51,8 +51,8 @@ class ConsoleAPI{
|
||||||
function __destruct(){
|
function __destruct(){
|
||||||
$this->server->deleteEvent($this->event);
|
$this->server->deleteEvent($this->event);
|
||||||
if(!defined("NO_THREADS")){
|
if(!defined("NO_THREADS")){
|
||||||
$this->loop->stop();
|
self::$loop->stop();
|
||||||
$this->loop->notify();
|
self::$loop->notify();
|
||||||
//@fclose($this->loop->fp);
|
//@fclose($this->loop->fp);
|
||||||
usleep(50000);
|
usleep(50000);
|
||||||
//$this->loop->join();
|
//$this->loop->join();
|
||||||
|
|
@ -68,10 +68,10 @@ class ConsoleAPI{
|
||||||
if(defined("NO_THREADS")){
|
if(defined("NO_THREADS")){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$line = $this->loop->line;
|
$line = self::$loop->line;
|
||||||
if($line !== false){
|
if($line !== false){
|
||||||
$line = preg_replace("#\\x1b\\x5b([^\\x1b]*\\x7e|[\\x40-\\x50])#", "", trim($line));
|
$line = preg_replace("#\\x1b\\x5b([^\\x1b]*\\x7e|[\\x40-\\x50])#", "", trim($line));
|
||||||
$this->loop->line = false;
|
self::$loop->line = false;
|
||||||
$output = $this->run($line, "console");
|
$output = $this->run($line, "console");
|
||||||
if($output != ""){
|
if($output != ""){
|
||||||
$mes = explode("\n", trim($output));
|
$mes = explode("\n", trim($output));
|
||||||
|
|
@ -80,7 +80,7 @@ class ConsoleAPI{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$this->loop->notify();
|
self::$loop->notify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -218,7 +218,7 @@ class ConsoleAPI{
|
||||||
}
|
}
|
||||||
return "TPS: " . $info["tps"] . ", Memory usage: " . $info["memory_usage"] . " (Peak " . $info["memory_peak_usage"] . ")";
|
return "TPS: " . $info["tps"] . ", Memory usage: " . $info["memory_usage"] . " (Peak " . $info["memory_peak_usage"] . ")";
|
||||||
case "stop":
|
case "stop":
|
||||||
$this->loop->stop = true;
|
self::$loop->stop = true;
|
||||||
$output .= "Stopping the server\n";
|
$output .= "Stopping the server\n";
|
||||||
$this->server->close();
|
$this->server->close();
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue