Skip to content

Commit 8ca19e8

Browse files
committed
Fix net-perf example if work_pool is nullptr
1 parent 69eb36e commit 8ca19e8

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

examples/perf/net-perf.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ static int ping_pong_client() {
9494

9595
auto run_ping_pong_worker = [&]() -> int {
9696
// Round-robin dispatch threads in WorkPool
97-
work_pool->thread_migrate();
97+
if (work_pool) {
98+
work_pool->thread_migrate();
99+
}
98100
// After the above call, this function begins to run in another vCPU
99101

100102
auto buf = malloc(FLAGS_buf_size);
@@ -238,7 +240,7 @@ static int echo_server() {
238240
// Define handler for new connections.
239241
// Every connection will be running in a new thread after it is accepted.
240242
auto handler = [&](photon::net::ISocketStream* sock) -> int {
241-
if (FLAGS_vcpu_num > 1) {
243+
if (work_pool) {
242244
// Migrate current thread (connection) to another vCPU in WorkPool.
243245
// The default policy is round-robin.
244246
work_pool->thread_migrate();

0 commit comments

Comments
 (0)