Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Jun 11, 2024
1 parent e0701a6 commit aea7b3c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
3 changes: 0 additions & 3 deletions ext-src/stubs/php_swoole_socket_coro.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,5 @@ public function getpeername(): false|array {}
public function isClosed(): bool {}
/** @param resource $stream */
public static function import($stream) : Socket | false {}
#ifdef SW_THREAD
public function __wakeup(): void {}
#endif
}
}
4 changes: 2 additions & 2 deletions ext-src/swoole_socket_coro.cc
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ SW_API void php_swoole_socket_set_error_properties(zval *zobject, Socket *socket
php_swoole_socket_set_error_properties(zobject, socket->errCode, socket->errMsg);
}

static zend_object *create_socket_object(Socket *socket) {
static zend_object *create_socket_object(Socket *socket) {
zval zobject;
zend_object *object = socket_coro_create_object(swoole_socket_coro_ce);
SocketObject *sock = (SocketObject *) socket_coro_fetch_object(object);
Expand Down Expand Up @@ -2185,7 +2185,7 @@ static PHP_METHOD(swoole_socket_coro, import) {
if (getsockopt(socket_fd, SOL_SOCKET, SO_DOMAIN, &sock_domain, &sock_domain_len) == 0) {
} else
#endif
if (getsockname(socket_fd, (struct sockaddr *) &addr, &addr_len) == 0) {
if (getsockname(socket_fd, (struct sockaddr *) &addr, &addr_len) == 0) {
sock_domain = addr.ss_family;
} else {
php_swoole_sys_error(E_WARNING, "getsockname() failed");
Expand Down
8 changes: 4 additions & 4 deletions tests/swoole_thread/pipe.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ if (empty($args)) {
$rdata = random_bytes(random_int(1024, 2048));
Co\run(function () use ($rdata) {
$sockets = swoole_coroutine_socketpair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
$thread = Thread::exec(__FILE__, $sockets, $rdata);
$thread = Thread::exec(__FILE__, $sockets[1], $rdata);
Assert::eq($sockets[0]->recv(8192), $rdata);
$thread->join();
echo "DONE\n";
});
} else {
$sockets = $args[0];
$socket = $args[0];
$rdata = $args[1];
// Child threads are not allowed to modify hook flags
Assert::false(Swoole\Runtime::enableCoroutine(SWOOLE_HOOK_ALL));
Co\run(function () use ($sockets, $rdata, $argv) {
Co\run(function () use ($socket, $rdata, $argv) {
usleep(100);
shell_exec('sleep 0.01');
$sockets[1]->send($rdata);
$socket->send($rdata);
});
exit(0);
}
Expand Down
5 changes: 2 additions & 3 deletions tests/swoole_thread/signal.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $args = Thread::getArguments();
if (empty($args)) {
Co\run(function () {
$sockets = swoole_coroutine_socketpair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
$thread = Thread::exec(__FILE__, $sockets);
$thread = Thread::exec(__FILE__, $sockets[0]);
$parent_pipe = $sockets[1];
Timer::after(500, function () {
echo "timer\n";
Expand All @@ -38,8 +38,7 @@ if (empty($args)) {
});
});
} else {
$sockets = $args[0];
$child_pipe = $sockets[0];
$child_pipe = $args[0];
Co\run(function () use ($child_pipe) {
// 收到父线程的指令,开始退出
echo $child_pipe->recv(8192), PHP_EOL;
Expand Down

0 comments on commit aea7b3c

Please sign in to comment.