Skip to content

Commit

Permalink
Reset on_bailout pointer to NULL when reactivating the coroutine sche…
Browse files Browse the repository at this point in the history
…duler
  • Loading branch information
matyhtf committed May 30, 2024
1 parent a1fa206 commit 25152cd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/coroutine/base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ void Coroutine::activate() {
coroutine::thread_context_init();
#endif
activated = true;
on_bailout = nullptr;
}

void Coroutine::deactivate() {
Expand Down
35 changes: 35 additions & 0 deletions tests/swoole_coroutine_scheduler/repeat.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
--TEST--
swoole_coroutine_scheduler: user yield and resume1
--SKIPIF--
<?php require __DIR__ . '/../include/skipif.inc'; ?>
--FILE--
<?php
require __DIR__ . '/../include/bootstrap.php';

\Swoole\Coroutine\run(function () {
echo 'scheduler 1: begin' . PHP_EOL;
Swoole\Coroutine\System::sleep(0.1);
echo 'scheduler 1: end' . PHP_EOL;
});

echo 'sleep: begin' . PHP_EOL;
usleep(100_000);
echo 'sleep: end' . PHP_EOL;

\Swoole\Coroutine\run(function () {
echo 'scheduler 2: begin' . PHP_EOL;
Swoole\Coroutine\System::sleep(0.1);
echo 'scheduler 2: end' . PHP_EOL;
});

echo 'DONE' . PHP_EOL;

?>
--EXPECT--
scheduler 1: begin
scheduler 1: end
sleep: begin
sleep: end
scheduler 2: begin
scheduler 2: end
DONE

0 comments on commit 25152cd

Please sign in to comment.