From 9734deb377806ea9e5b239b23583cbe304ddea48 Mon Sep 17 00:00:00 2001 From: hantianfeng Date: Thu, 15 Aug 2024 19:43:42 +0800 Subject: [PATCH] [test][zts] fix tests [5] --- .github/workflows/iouring.yml | 1 + include/swoole_socket.h | 8 ++++++++ src/os/process_pool.cc | 9 +-------- tests/include/functions.php | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/iouring.yml b/.github/workflows/iouring.yml index aab6457ec01..68e4cc92570 100644 --- a/.github/workflows/iouring.yml +++ b/.github/workflows/iouring.yml @@ -5,6 +5,7 @@ on: [push, pull_request] jobs: test-linux: runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[test]')" strategy: fail-fast: false matrix: diff --git a/include/swoole_socket.h b/include/swoole_socket.h index 8d647565d9b..c43e27996e6 100644 --- a/include/swoole_socket.h +++ b/include/swoole_socket.h @@ -492,6 +492,14 @@ struct Socket { return ::read(fd, __buf, __len); } + ssize_t read_sync(void *__buf, size_t __len, int timeout_ms = -1) { + if (wait_event(timeout_ms, SW_EVENT_READ) == SW_OK) { + return read(__buf, __len); + } else { + return -1; + } + } + int shutdown(int __how) { return ::shutdown(fd, __how); } diff --git a/src/os/process_pool.cc b/src/os/process_pool.cc index 062bb24ec90..c95196fd9e0 100644 --- a/src/os/process_pool.cc +++ b/src/os/process_pool.cc @@ -544,10 +544,6 @@ static int ProcessPool_worker_loop_with_task_protocol(ProcessPool *pool, Worker out.mtype = worker->id + 1; } - if (worker->pipe_worker) { - worker->pipe_worker->set_block(); - } - while (pool->running && !SwooleWG.shutdown && task_n > 0) { /** * fetch task @@ -575,10 +571,7 @@ static int ProcessPool_worker_loop_with_task_protocol(ProcessPool *pool, Worker } pool->stream_info_->last_connection = conn; } else { - n = worker->pipe_worker->read(&out.buf, sizeof(out.buf)); - if (n < 0 && errno != EINTR) { - swoole_sys_warning("read(%d) failed", worker->pipe_worker->fd); - } + n = worker->pipe_worker->read_sync(&out.buf, sizeof(out.buf)); } /** diff --git a/tests/include/functions.php b/tests/include/functions.php index 3701b3dee9a..1ada025186d 100644 --- a/tests/include/functions.php +++ b/tests/include/functions.php @@ -90,7 +90,7 @@ function get_one_free_port(): int function get_constant_port(string $str, int $base = 9500): int { - return $base + crc32(__FILE__) % 1000; + return $base + crc32(__FILE__) % 10000; } function get_one_free_port_ipv6(): int