mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
Fixed race condition in API schedule()
This commit is contained in:
parent
29cd858622
commit
f47fa6d5dc
@ -537,12 +537,13 @@ class PocketMinecraftServer{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$add = "";
|
$add = "";
|
||||||
|
$chcnt = $this->scheduleCnt++;
|
||||||
if($repeat === false){
|
if($repeat === false){
|
||||||
$add = ' unset($this->schedule['.$this->scheduleCnt.']);';
|
$add = ' unset($this->schedule['.$chcnt.']);';
|
||||||
}
|
}
|
||||||
$this->schedule[$this->scheduleCnt] = array($callback, $data, $eventName);
|
$this->schedule[$chcnt] = array($callback, $data, $eventName);
|
||||||
$this->action(50000 * $ticks, '$schedule = $this->schedule['.$this->scheduleCnt.'];'.$add.'if(!is_callable($schedule[0])){unset($this->schedule['.$this->scheduleCnt.']);return false;} call_user_func($schedule[0], $schedule[1], $schedule[2]);', (bool) $repeat);
|
$this->action(50000 * $ticks, '$schedule = $this->schedule['.$chcnt.'];'.$add.'if(!is_callable($schedule[0])){unset($this->schedule['.$chcnt.']);return false;} call_user_func($schedule[0], $schedule[1], $schedule[2]);', (bool) $repeat);
|
||||||
return $this->scheduleCnt++;
|
return $chcnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function action($microseconds, $code, $repeat = true){
|
public function action($microseconds, $code, $repeat = true){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user