diff --git a/src/io_threads.c b/src/io_threads.c index 95d5895d0..c9345d72e 100644 --- a/src/io_threads.c +++ b/src/io_threads.c @@ -164,9 +164,9 @@ void waitForClientIO(client *c) { void adjustIOThreadsByEventLoad(int numevents, int increase_only) { if (server.io_threads_num == 1) return; /* All I/O is being done by the main thread. */ debugServerAssertWithInfo(NULL, NULL, server.io_threads_num > 1); - - int target_threads = - server.events_per_io_thread == 0 ? server.io_threads_num : numevents / server.events_per_io_thread; + /* When events_per_io_thread is set to 0, we offload all events to the IO threads. + * This is used mainly for testing purposes. */ + int target_threads = server.events_per_io_thread == 0 ? (numevents + 1) : numevents / server.events_per_io_thread; target_threads = max(1, min(target_threads, server.io_threads_num));