Skip to content

Commit

Permalink
fix tests [3], --filter=[unit]
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Oct 23, 2024
1 parent 1ce0a5c commit e2df2dc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ext-src/swoole_http_response.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@ static PHP_METHOD(swoole_http_response, create) {
if (instanceof_function(Z_OBJCE_P(zobject), swoole_server_ce)) {
serv = php_swoole_server_get_and_check_server(zobject);
if (serv->get_connection_verify(fd) == nullptr) {
php_swoole_fatal_error(E_WARNING, "parameter $2 must be valid connection session id");
php_swoole_fatal_error(E_WARNING, "parameter $2 %d must be valid connection session id", fd);
RETURN_FALSE;
}
} else if (sw_zval_is_co_socket(zobject)) {
Expand Down
3 changes: 3 additions & 0 deletions src/server/master.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2034,6 +2034,9 @@ void Server::init_pipe_sockets(MessageBus *mb) {

SW_LOOP_N(n) {
Worker *worker = get_worker(i);
if (i >= worker_num && task_ipc_mode != TASK_IPC_UNIXSOCK) {
continue;
}
mb->init_pipe_socket(worker->pipe_master);
mb->init_pipe_socket(worker->pipe_worker);
}
Expand Down
7 changes: 5 additions & 2 deletions tests/swoole_server/base/shutdown.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ require __DIR__ . '/../../include/bootstrap.php';
$pm = new SwooleTest\ProcessManager;
$pm->initRandomData(1);
$pm->parentFunc = function () use ($pm) {
go(function () use ($pm) {
Co\run(function () use ($pm) {
$client = new Co\Client(SWOOLE_SOCK_TCP);
Assert::assert($client->connect('127.0.0.1', $pm->getFreePort()));
Assert::assert($client->send($pm->getRandomData()) > 0);
});
$pm->kill();
$pm->wait();
};
$pm->childFunc = function () use ($pm) {
$server = new Swoole\Server('127.0.0.1', $pm->getFreePort(), SWOOLE_BASE);
Expand All @@ -28,8 +30,9 @@ $pm->childFunc = function () use ($pm) {
Assert::same($data, $pm->getRandomData());
$server->shutdown();
});
$server->on('shutdown', function () {
$server->on('shutdown', function () use ($pm) {
echo "SHUTDOWN\n";
$pm->wakeup();
});
$server->start();
};
Expand Down
10 changes: 7 additions & 3 deletions tests/swoole_server/task/task_ipc_mode_3.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ swoole_server/task: task_ipc_mode = 3
--FILE--
<?php
require __DIR__ . '/../../include/bootstrap.php';

use Swoole\Http\Response;
use Swoole\Http\Request;

$atomic = new Swoole\Atomic;
$pm = new SwooleTest\ProcessManager;
$pm->parentFunc = function ($pid) use ($pm) {
Expand All @@ -15,7 +19,7 @@ $pm->parentFunc = function ($pid) use ($pm) {
$pm->kill();
};
$pm->childFunc = function () use ($pm, $atomic) {
$server = new Swoole\Http\Server('127.0.0.1', $pm->getFreePort(), SERVER_MODE_RANDOM);
$server = new Swoole\Http\Server('127.0.0.1', $pm->getFreePort(), SWOOLE_PROCESS);
$server->set([
'log_file' => '/dev/null',
'open_tcp_nodelay' => true,
Expand All @@ -29,12 +33,12 @@ $pm->childFunc = function () use ($pm, $atomic) {
$pm->wakeup();
}
});
$server->on('request', function (Swoole\Http\Request $request, Swoole\Http\Response $response) use ($server) {
$server->on('request', function (Request $request, Response $response) use ($server) {
$response->detach();
$server->task($response->fd);
});
$server->on('task', function ($server, $task_id, $worker_id, string $fd) {
$response = Swoole\Http\Response::create($fd);
$response = Response::create($server, $fd);
$response->end("Hello Swoole!\n");
});
$server->on('finish', function () { });
Expand Down

0 comments on commit e2df2dc

Please sign in to comment.