Handling of aeResizeSetSize's return code for current thread
Former-commit-id: c25fb3d74fb9e7adb6ad7ef730355e325e982cd2
This commit is contained in:
parent
d25fc8a950
commit
877f94734c
@ -373,6 +373,11 @@ int aeGetSetSize(aeEventLoop *eventLoop) {
|
|||||||
return eventLoop->setsize;
|
return eventLoop->setsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return the current EventLoop. */
|
||||||
|
aeEventLoop *aeGetCurrentEventLoop(){
|
||||||
|
return g_eventLoopThisThread;
|
||||||
|
}
|
||||||
|
|
||||||
/* Tells the next iteration/s of the event processing to set timeout of 0. */
|
/* Tells the next iteration/s of the event processing to set timeout of 0. */
|
||||||
void aeSetDontWait(aeEventLoop *eventLoop, int noWait) {
|
void aeSetDontWait(aeEventLoop *eventLoop, int noWait) {
|
||||||
if (noWait)
|
if (noWait)
|
||||||
|
1
src/ae.h
1
src/ae.h
@ -160,6 +160,7 @@ const char *aeGetApiName(void);
|
|||||||
void aeSetBeforeSleepProc(aeEventLoop *eventLoop, aeBeforeSleepProc *beforesleep, int flags);
|
void aeSetBeforeSleepProc(aeEventLoop *eventLoop, aeBeforeSleepProc *beforesleep, int flags);
|
||||||
void aeSetAfterSleepProc(aeEventLoop *eventLoop, aeBeforeSleepProc *aftersleep, int flags);
|
void aeSetAfterSleepProc(aeEventLoop *eventLoop, aeBeforeSleepProc *aftersleep, int flags);
|
||||||
int aeGetSetSize(aeEventLoop *eventLoop);
|
int aeGetSetSize(aeEventLoop *eventLoop);
|
||||||
|
aeEventLoop *aeGetCurrentEventLoop();
|
||||||
int aeResizeSetSize(aeEventLoop *eventLoop, int setsize);
|
int aeResizeSetSize(aeEventLoop *eventLoop, int setsize);
|
||||||
void aeSetDontWait(aeEventLoop *eventLoop, int noWait);
|
void aeSetDontWait(aeEventLoop *eventLoop, int noWait);
|
||||||
|
|
||||||
|
@ -2273,14 +2273,33 @@ static int updateMaxclients(long long val, long long prev, const char **err) {
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
/* Change the SetSize for the current thread first.
|
||||||
|
* If any error, return the error message to the client, otherwise, continue to do the same for other threads */
|
||||||
|
if ((unsigned int) aeGetSetSize(aeGetCurrentEventLoop()) <
|
||||||
|
g_pserver->maxclients + CONFIG_FDSET_INCR)
|
||||||
|
{
|
||||||
|
if (aeResizeSetSize(aeGetCurrentEventLoop(),
|
||||||
|
g_pserver->maxclients + CONFIG_FDSET_INCR) == AE_ERR)
|
||||||
|
{
|
||||||
|
*err = "The event loop API used by Redis is not able to handle the specified number of clients";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
serverLog(LL_DEBUG,"Successfully changed the setsize for current thread %d", ielFromEventLoop(aeGetCurrentEventLoop()));
|
||||||
|
}
|
||||||
|
|
||||||
for (int iel = 0; iel < cserver.cthreads; ++iel)
|
for (int iel = 0; iel < cserver.cthreads; ++iel)
|
||||||
{
|
{
|
||||||
|
if (g_pserver->rgthreadvar[iel].el == aeGetCurrentEventLoop())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ((unsigned int) aeGetSetSize(g_pserver->rgthreadvar[iel].el) <
|
if ((unsigned int) aeGetSetSize(g_pserver->rgthreadvar[iel].el) <
|
||||||
g_pserver->maxclients + CONFIG_FDSET_INCR)
|
g_pserver->maxclients + CONFIG_FDSET_INCR)
|
||||||
{
|
{
|
||||||
int res = aePostFunction(g_pserver->rgthreadvar[iel].el, [iel] {
|
int res = aePostFunction(g_pserver->rgthreadvar[iel].el, [iel] {
|
||||||
if (aeResizeSetSize(g_pserver->rgthreadvar[iel].el, g_pserver->maxclients + CONFIG_FDSET_INCR) == AE_ERR) {
|
if (aeResizeSetSize(g_pserver->rgthreadvar[iel].el, g_pserver->maxclients + CONFIG_FDSET_INCR) == AE_ERR) {
|
||||||
serverPanic("Failed to change the setsize for Thread %d", iel);
|
serverLog(LL_WARNING,"Failed to change the setsize for Thread %d", iel);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -2290,6 +2309,7 @@ static int updateMaxclients(long long val, long long prev, const char **err) {
|
|||||||
*err = msg;
|
*err = msg;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
serverLog(LL_DEBUG,"Successfully post the request to change the setsize for thread %d", iel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user