Skip to content

Commit 20b97f6

Browse files
Fix bug #5699 (#5701)
1 parent 59d652a commit 20b97f6

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

ext-src/swoole_coroutine.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,11 @@ void PHPCoroutine::fiber_context_try_destroy(PHPContext *ctx) {
864864
}
865865

866866
zend_fiber_status PHPCoroutine::get_fiber_status(PHPContext *ctx) {
867+
// main_context
868+
if (ctx->fiber_context == EG(main_fiber_context)) {
869+
return ZEND_FIBER_STATUS_RUNNING;
870+
}
871+
867872
switch (ctx->co->get_state()) {
868873
case Coroutine::STATE_INIT:
869874
return ZEND_FIBER_STATUS_INIT;

tests/swoole_coroutine/bug_5699.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
swoole_coroutine: Github bug #5699
3+
--SKIPIF--
4+
<?php require __DIR__ . '/../include/skipif.inc'; ?>
5+
--FILE--
6+
<?php
7+
require __DIR__ . '/../include/bootstrap.php';
8+
ini_set('swoole.enable_fiber_mock', 'On');
9+
use function Swoole\Coroutine\run;
10+
11+
run(function() {
12+
sleep(1);
13+
});
14+
?>
15+
--EXPECT--

0 commit comments

Comments
 (0)