Skip to content

Commit 1131a51

Browse files
committed
Fix all_asleep.phpt test
1 parent 8d008a1 commit 1131a51

File tree

3 files changed

+29
-17
lines changed

3 files changed

+29
-17
lines changed

ext-src/php_swoole_library.h

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
+----------------------------------------------------------------------+
1515
*/
1616

17-
/* $Id: 4d81858f42a199c1e7a68e13357dbe793da9e9e8 */
17+
/* $Id: 59666fa435d463ccd47641c5bff7c4dd684c0bc6 */
1818

1919
#ifndef SWOOLE_LIBRARY_H
2020
#define SWOOLE_LIBRARY_H
@@ -9570,28 +9570,37 @@ static const char* swoole_library_source_core_coroutine_functions =
95709570
"{\n"
95719571
" $all_coroutines = Coroutine::listCoroutines();\n"
95729572
" $count = Coroutine::stats()['coroutine_num'];\n"
9573-
" echo \"\\n ===================================================================\",\n"
9573+
"\n"
9574+
" // coroutine deadlock detected, header\n"
9575+
" $hr_width = 64 + strlen(strval($count));\n"
9576+
" $hr1 = str_repeat('=', $hr_width);\n"
9577+
" $hr2 = str_repeat('-', $hr_width);\n"
9578+
" echo '',\n"
9579+
" \"\\n {$hr1}\",\n"
95749580
" \"\\n [FATAL ERROR]: all coroutines (count: {$count}) are asleep - deadlock!\",\n"
9575-
" \"\\n ===================================================================\",\n"
9576-
" \"\\n \";\n"
9581+
" \"\\n {$hr1}\",\n"
9582+
" \"\\n\";\n"
95779583
"\n"
9584+
" // print all coroutine backtraces\n"
95789585
" $options = Coroutine::getOptions();\n"
95799586
" if (empty($options['deadlock_check_disable_trace'])) {\n"
95809587
" $index = 0;\n"
95819588
" $limit = empty($options['deadlock_check_limit']) ? 32 : intval($options['deadlock_check_limit']);\n"
95829589
" $depth = empty($options['deadlock_check_depth']) ? 32 : intval($options['deadlock_check_depth']);\n"
95839590
" foreach ($all_coroutines as $cid) {\n"
9584-
" echo \"\\n [Coroutine-{$cid}]\";\n"
9585-
" echo \"\\n --------------------------------------------------------------------\\n\";\n"
9591+
" echo \"\\n [Coroutine-{$cid}]\";\n"
9592+
" echo \"\\n {$hr2}\\n\";\n"
95869593
" echo Coroutine::printBackTrace($cid, DEBUG_BACKTRACE_IGNORE_ARGS, $depth);\n"
9587-
" echo \"\\n \";\n"
95889594
" $index++;\n"
95899595
" // limit the number of maximum outputs\n"
95909596
" if ($index >= $limit) {\n"
95919597
" break;\n"
95929598
" }\n"
95939599
" }\n"
95949600
" }\n"
9601+
"\n"
9602+
" // footer\n"
9603+
" echo \"\\n {$hr1}\\n\";\n"
95959604
"}\n";
95969605

95979606
static const char* swoole_library_source_ext_curl =

ext-src/swoole_coroutine.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,9 @@ void PHPCoroutine::deadlock_check() {
478478
zend::function::call(R"(\Swoole\Coroutine\deadlock_check)", 0, nullptr);
479479
} else {
480480
printf("\n ==================================================================="
481-
"\n [FATAL ERROR]: all coroutines (count: %lu) are asleep - deadlock!"
481+
"\n [FATAL ERROR]: all coroutines (count: %lu) are asleep - deadlock! "
482482
"\n ==================================================================="
483-
"\n ",
483+
"\n",
484484
Coroutine::count());
485485
}
486486
}

tests/swoole_coroutine/all_asleep.phpt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,23 @@ Co\run(function () {
3535
echo "DONE\n";
3636
?>
3737
--EXPECTF--
38-
===================================================================
39-
[FATAL ERROR]: all coroutines (count: 2) are asleep - deadlock!
40-
===================================================================
4138

42-
[Coroutine-3]
43-
--------------------------------------------------------------------
39+
=================================================================
40+
[FATAL ERROR]: all coroutines (count: 2) are asleep - deadlock!
41+
=================================================================
42+
43+
[Coroutine-3]
44+
-----------------------------------------------------------------
45+
%A
4446
%A
4547
%A
4648

47-
48-
[Coroutine-2]
49-
--------------------------------------------------------------------
49+
[Coroutine-2]
50+
-----------------------------------------------------------------
51+
%A
5052
%A
5153
%A
5254
%A
5355

56+
=================================================================
5457
DONE

0 commit comments

Comments
 (0)