From c65a68b15bd304dcb3c9902ca3c4b8d1c8f15aa5 Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 21 Apr 2017 16:27:38 +0200 Subject: [PATCH] Check event loop creation return value. Fix #3951. Normally we never check for OOM conditions inside Redis since the allocator will always return a pointer or abort the program on OOM conditons. However we cannot have control on epool_create(), that may fail for kernel OOM (according to the manual page) even if all the parameters are correct, so the function aeCreateEventLoop() may indeed return NULL and this condition must be checked. --- src/server.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/server.c b/src/server.c index db853b836..72914c53b 100644 --- a/src/server.c +++ b/src/server.c @@ -1782,6 +1782,12 @@ void initServer(void) { createSharedObjects(); adjustOpenFilesLimit(); server.el = aeCreateEventLoop(server.maxclients+CONFIG_FDSET_INCR); + if (server.el == NULL) { + serverLog(LL_WARNING, + "Failed creating the event loop. Error message: '%s'", + strerror(errno)); + exit(1); + } server.db = zmalloc(sizeof(redisDb)*server.dbnum); /* Open the TCP listening socket for the user commands. */