Skip to content

Commit aea7b3c

Browse files
committed
fix tests
1 parent e0701a6 commit aea7b3c

File tree

4 files changed

+8
-12
lines changed

4 files changed

+8
-12
lines changed

ext-src/stubs/php_swoole_socket_coro.stub.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,5 @@ public function getpeername(): false|array {}
3535
public function isClosed(): bool {}
3636
/** @param resource $stream */
3737
public static function import($stream) : Socket | false {}
38-
#ifdef SW_THREAD
39-
public function __wakeup(): void {}
40-
#endif
4138
}
4239
}

ext-src/swoole_socket_coro.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ SW_API void php_swoole_socket_set_error_properties(zval *zobject, Socket *socket
821821
php_swoole_socket_set_error_properties(zobject, socket->errCode, socket->errMsg);
822822
}
823823

824-
static zend_object *create_socket_object(Socket *socket) {
824+
static zend_object *create_socket_object(Socket *socket) {
825825
zval zobject;
826826
zend_object *object = socket_coro_create_object(swoole_socket_coro_ce);
827827
SocketObject *sock = (SocketObject *) socket_coro_fetch_object(object);
@@ -2185,7 +2185,7 @@ static PHP_METHOD(swoole_socket_coro, import) {
21852185
if (getsockopt(socket_fd, SOL_SOCKET, SO_DOMAIN, &sock_domain, &sock_domain_len) == 0) {
21862186
} else
21872187
#endif
2188-
if (getsockname(socket_fd, (struct sockaddr *) &addr, &addr_len) == 0) {
2188+
if (getsockname(socket_fd, (struct sockaddr *) &addr, &addr_len) == 0) {
21892189
sock_domain = addr.ss_family;
21902190
} else {
21912191
php_swoole_sys_error(E_WARNING, "getsockname() failed");

tests/swoole_thread/pipe.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ if (empty($args)) {
1717
$rdata = random_bytes(random_int(1024, 2048));
1818
Co\run(function () use ($rdata) {
1919
$sockets = swoole_coroutine_socketpair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
20-
$thread = Thread::exec(__FILE__, $sockets, $rdata);
20+
$thread = Thread::exec(__FILE__, $sockets[1], $rdata);
2121
Assert::eq($sockets[0]->recv(8192), $rdata);
2222
$thread->join();
2323
echo "DONE\n";
2424
});
2525
} else {
26-
$sockets = $args[0];
26+
$socket = $args[0];
2727
$rdata = $args[1];
2828
// Child threads are not allowed to modify hook flags
2929
Assert::false(Swoole\Runtime::enableCoroutine(SWOOLE_HOOK_ALL));
30-
Co\run(function () use ($sockets, $rdata, $argv) {
30+
Co\run(function () use ($socket, $rdata, $argv) {
3131
usleep(100);
3232
shell_exec('sleep 0.01');
33-
$sockets[1]->send($rdata);
33+
$socket->send($rdata);
3434
});
3535
exit(0);
3636
}

tests/swoole_thread/signal.phpt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ $args = Thread::getArguments();
1919
if (empty($args)) {
2020
Co\run(function () {
2121
$sockets = swoole_coroutine_socketpair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
22-
$thread = Thread::exec(__FILE__, $sockets);
22+
$thread = Thread::exec(__FILE__, $sockets[0]);
2323
$parent_pipe = $sockets[1];
2424
Timer::after(500, function () {
2525
echo "timer\n";
@@ -38,8 +38,7 @@ if (empty($args)) {
3838
});
3939
});
4040
} else {
41-
$sockets = $args[0];
42-
$child_pipe = $sockets[0];
41+
$child_pipe = $args[0];
4342
Co\run(function () use ($child_pipe) {
4443
// 收到父线程的指令,开始退出
4544
echo $child_pipe->recv(8192), PHP_EOL;

0 commit comments

Comments
 (0)