Enable load balancing of UNIX sockets across threads

Former-commit-id: 46d6caa47c57fa13055615dfc2376b0962468b81
This commit is contained in:
John Sully 2019-06-11 01:34:36 -04:00
parent 88b5a4e25f
commit c64b6127ea

View File

@ -1175,7 +1175,17 @@ void acceptUnixHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
serverLog(LL_VERBOSE,"Accepted connection to %s", g_pserver->unixsocket);
aeAcquireLock();
int ielTarget = rand() % cserver.cthreads;
if (ielTarget == ielCur)
{
acceptCommonHandler(cfd,CLIENT_UNIX_SOCKET,NULL, ielCur);
}
else
{
aePostFunction(g_pserver->rgthreadvar[ielTarget].el, [cfd, ielTarget]{
acceptCommonHandler(cfd,CLIENT_UNIX_SOCKET,NULL, ielTarget);
});
}
aeReleaseLock();
}