mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 12:39:43 +00:00
Fixed race condition in API addHandler()
This commit is contained in:
parent
aa22acee5f
commit
29cd858622
1 changed files with 5 additions and 4 deletions
|
|
@ -191,10 +191,11 @@ class PocketMinecraftServer{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$priority = (int) $priority;
|
$priority = (int) $priority;
|
||||||
$this->handlers[$this->handCnt] = $callable;
|
$hnid = $this->handCnt++;
|
||||||
$this->query("INSERT INTO handlers (ID, name, priority) VALUES (".$this->handCnt.", '".str_replace("'", "\\'", $event)."', ".$priority.");");
|
$this->handlers[$hnid] = $callable;
|
||||||
console("[INTERNAL] New handler ".(is_array($callable) ? get_class($callable[0])."::".$callable[1]:$callable)." to special event ".$event." (ID ".$this->handCnt.")", true, true, 3);
|
$this->query("INSERT INTO handlers (ID, name, priority) VALUES (".$hnid.", '".str_replace("'", "\\'", $event)."', ".$priority.");");
|
||||||
return $this->handCnt++;
|
console("[INTERNAL] New handler ".(is_array($callable) ? get_class($callable[0])."::".$callable[1]:$callable)." to special event ".$event." (ID ".$hnid.")", true, true, 3);
|
||||||
|
return $hnid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle($event, &$data){
|
public function handle($event, &$data){
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue