Threaded IO: use main thread to handle read work

This commit is contained in:
zhaozhao.zz 2019-05-21 11:42:10 +08:00 committed by antirez
parent 0a3410db70
commit 1f76ff2fb9

View File

@ -2885,7 +2885,7 @@ int handleClientsWithPendingReadsUsingThreads(void) {
int item_id = 0;
while((ln = listNext(&li))) {
client *c = listNodeValue(ln);
int target_id = item_id % server.io_threads_num;
int target_id = item_id % (server.io_threads_num+1);
listAddNodeTail(io_threads_list[target_id],c);
item_id++;
}
@ -2898,6 +2898,13 @@ int handleClientsWithPendingReadsUsingThreads(void) {
io_threads_pending[j] = count;
}
listRewind(io_threads_list[server.io_threads_num],&li);
while((ln = listNext(&li))) {
client *c = listNodeValue(ln);
readQueryFromClient(NULL,c->fd,c,0);
}
listEmpty(io_threads_list[server.io_threads_num]);
/* Wait for all threads to end their work. */
while(1) {
unsigned long pending = 0;