Skip to content

Commit 1982bb0

Browse files
committed
warning free, fix tests
1 parent 97d9437 commit 1982bb0

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

include/swoole_coroutine_context.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
#include <mutex>
2525
#elif !defined(SW_USE_ASM_CONTEXT)
2626
#define USE_UCONTEXT 1
27+
#ifndef _XOPEN_SOURCE
2728
#define _XOPEN_SOURCE
29+
#endif
2830
#include <ucontext.h>
2931
#else
3032
#define USE_ASM_CONTEXT 1

tests/swoole_table/force_unlock.phpt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,26 @@ $data = [
2222
];
2323
$table->set('test', $data);
2424

25-
(new Process(function () use ($table) {
26-
$str = str_repeat('A', 4 * 1024 * 1024);
25+
$proc = new Process(function () use ($table) {
26+
$str = str_repeat('A', 5 * 1024 * 1024);
2727
// Fatal error: memory exhausted
2828
$data = $table->get('test');
2929
var_dump(strlen($data['string']));
3030
var_dump(strlen($str));
3131
var_dump(memory_get_usage());
32-
}))->start();
32+
}, true, SOCK_STREAM);
3333

34-
Process::wait();
34+
$proc->start();
35+
36+
$exit_status = Process::wait();
37+
Assert::eq($exit_status['code'], 255);
38+
Assert::contains($proc->read(), 'Fatal error: Allowed memory');
3539

3640
$data = $table->get('test');
3741
Assert::eq(strlen($data['string']), $str_size);
3842
Assert::eq($data['string'], $str_value);
3943
echo "Done\n";
4044
?>
4145
--EXPECTF--
42-
Fatal error: Allowed memory size of %d bytes exhausted at %s (tried to allocate %d bytes) in %s on line %d
4346
[%s] WARNING lock: lock process[%d] not exists, force unlock
4447
Done

0 commit comments

Comments
 (0)