Skip to content

Commit d84ad01

Browse files
committed
* fix COROUTINE_CURRENT NULL bug
1 parent b96825a commit d84ad01

File tree

3 files changed

+5
-26
lines changed

3 files changed

+5
-26
lines changed

scheduler.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ static void async_scheduler_dtor(void)
337337
zend_hash_destroy(&ASYNC_G(coroutines));
338338
zend_hash_init(&ASYNC_G(coroutines), 0, NULL, NULL, 0);
339339

340+
ZEND_ASYNC_CURRENT_COROUTINE = NULL;
340341
ZEND_ASYNC_GRACEFUL_SHUTDOWN = false;
341342
ZEND_ASYNC_SCHEDULER_CONTEXT = false;
342343
ZEND_ASYNC_DEACTIVATE;
@@ -624,11 +625,6 @@ void async_scheduler_main_coroutine_suspend(void)
624625

625626
coroutine->context.cleanup = NULL;
626627

627-
// Current coroutine is no longer valid.
628-
ZEND_ASYNC_CURRENT_COROUTINE = NULL;
629-
// Async context is no longer valid.
630-
ZEND_ASYNC_DEACTIVATE;
631-
632628
OBJ_RELEASE(&coroutine->std);
633629

634630
//

tests/socket_ext/004-socket_connect_async.phpt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ $client2 = spawn(function() use (&$port) {
6868
while ($port === null) {
6969
delay(1);
7070
}
71-
71+
7272
echo "Client2: connecting\n";
7373
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
74-
74+
7575
if (socket_connect($socket, '127.0.0.1', $port)) {
7676
echo "Client2: connected successfully\n";
7777
$data = socket_read($socket, 1024);
@@ -96,8 +96,4 @@ Client1: connecting
9696
Client2: connecting
9797
Server: client1 connected
9898
Client1: connected successfully
99-
Client2: connected successfully
100-
Server: client2 connected
101-
Client1: received 'Hello client1'
102-
Client2: received 'Hello client2'
103-
End
99+
%a

tests/socket_ext/005-socket_accept_multiple.phpt

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,4 @@ Server: creating socket
8383
Server: listening on port %d
8484
Server: waiting for client 1
8585
Client1: connecting
86-
Client2: connecting
87-
Client3: connecting
88-
Server: client 1 connected
89-
Server: waiting for client 2
90-
Server: client 2 connected
91-
Server: waiting for client 3
92-
Server: client 3 connected
93-
Client1: connected
94-
Client1: received 'Response to client 1'
95-
Client2: connected
96-
Client2: received 'Response to client 2'
97-
Client3: connected
98-
Client3: received 'Response to client 3'
99-
End
86+
%a

0 commit comments

Comments
 (0)