freeMemoryIfNeeded() minor refactoring

This commit is contained in:
antirez
2012-02-06 16:56:42 +01:00
parent c1ef6ffe8a
commit 8b7c3455b9
3 changed files with 23 additions and 23 deletions

View File

@ -1315,3 +1315,24 @@ void asyncCloseClientOnOutputBufferLimitReached(redisClient *c) {
sdsfree(client);
}
}
/* Helper function used by freeMemoryIfNeeded() in order to flush slaves
* output buffers without returning control to the event loop. */
void flushSlavesOutputBuffers(void) {
listIter li;
listNode *ln;
listRewind(server.slaves,&li);
while((ln = listNext(&li))) {
redisClient *slave = listNodeValue(ln);
int events;
events = aeGetFileEvents(server.el,slave->fd);
if (events & AE_WRITABLE &&
slave->replstate == REDIS_REPL_ONLINE &&
listLength(slave->reply))
{
sendReplyToClient(server.el,slave->fd,slave,0);
}
}
}