Skip to content

Commit 0667e22

Browse files
committed
Add tests [18] --filter=[core] --asan
1 parent a76728f commit 0667e22

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

core-tests/src/os/process_pool.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static void test_func_stream_protocol(ProcessPool &pool) {
8080

8181
TEST(process_pool, tcp) {
8282
ProcessPool pool{};
83-
int svr_port = swoole::test::get_random_port();
83+
int svr_port = test::get_random_port();
8484
ASSERT_EQ(pool.create(1, 0, SW_IPC_SOCKET), SW_OK);
8585
ASSERT_EQ(pool.listen(TEST_HOST, svr_port, 128), SW_OK);
8686

@@ -238,15 +238,24 @@ TEST(process_pool, reload) {
238238

239239
pool.onWorkerStart = [](ProcessPool *pool, Worker *worker) {
240240
test::counter_incr(0);
241+
current_pool = pool;
242+
243+
DEBUG() << "onWorkerStart " << worker->id << "\n";
241244

242245
sysv_signal(SIGTERM, SIG_IGN);
246+
sysv_signal(SIGRTMIN, [](int) { current_pool->reopen_logger(); });
247+
sysv_signal(SIGWINCH, [](int) { current_pool->reopen_logger(); });
243248

244249
while (true) {
245250
sleep(10000);
246251
}
247252
};
248253

249-
pool.onStart = [](ProcessPool *pool) { swoole_timer_after(100, [pool](TIMER_PARAMS) { pool->reload(); }); };
254+
pool.onStart = [](ProcessPool *pool) {
255+
pool->reopen_logger();
256+
swoole_timer_after(50, [pool](TIMER_PARAMS) { kill(pool->get_worker(0)->pid, SIGRTMIN); });
257+
swoole_timer_after(100, [pool](TIMER_PARAMS) { pool->reload(); });
258+
};
250259

251260
pool.onBeforeReload = [](ProcessPool *pool) { DEBUG() << "onBeforeReload\n"; };
252261

src/os/process_pool.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,10 @@ void ReloadTask::add_workers(Worker *list, size_t n) {
11561156
}
11571157

11581158
void ReloadTask::add_timeout_killer(int timeout) {
1159-
timer = swoole_timer_add(sec2msec(timeout), false, [this](Timer *timer, TimerNode *tnode) { kill_all(); });
1159+
timer = swoole_timer_add(sec2msec(timeout), false, [this](Timer *, TimerNode *) {
1160+
kill_all();
1161+
timer = nullptr;
1162+
});
11601163
}
11611164

11621165
bool ReloadTask::remove(pid_t pid) {

0 commit comments

Comments
 (0)