diff options
author | antirez <antirez@gmail.com> | 2014-12-04 10:54:31 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2014-12-04 11:07:55 +0100 |
commit | 7c671c09a157164daa9b8cadf21fb9c064492d20 (patch) | |
tree | 3bab610eec18cf09ed27db3c5910981a98d3e8cf /src/redis.c | |
parent | d56ef62983168dc74bc3844e7ed8a5ad097614c8 (diff) | |
download | redis-7c671c09a157164daa9b8cadf21fb9c064492d20.tar.gz |
Check that tcp-backlog is matched by /proc/sys/net/core/somaxconn.
Diffstat (limited to 'src/redis.c')
-rw-r--r-- | src/redis.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/redis.c b/src/redis.c index 3cbe753fe..289e37791 100644 --- a/src/redis.c +++ b/src/redis.c @@ -1535,6 +1535,23 @@ void adjustOpenFilesLimit(void) { } } +/* Check that server.tcp_backlog can be actually enforced in Linux according + * to the value of /proc/sys/net/core/somaxconn, or warn about it. */ +void checkTcpBacklogSettings(void) { +#ifdef HAVE_PROC_SOMAXCONN + FILE *fp = fopen("/proc/sys/net/core/somaxconn","r"); + char buf[1024]; + if (!fp) return; + if (fgets(buf,sizeof(buf),fp) != NULL) { + int somaxconn = atoi(buf); + if (somaxconn > 0 && somaxconn < server.tcp_backlog) { + redisLog(REDIS_WARNING,"WARNING: The TCP backlog setting of %d cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of %d.", server.tcp_backlog, somaxconn); + } + } + fclose(fp); +#endif +} + /* Initialize a set of file descriptors to listen to the specified 'port' * binding the addresses specified in the Redis server configuration. * @@ -3346,6 +3363,7 @@ int main(int argc, char **argv) { #ifdef __linux__ linuxMemoryWarnings(); #endif + checkTcpBacklogSettings(); loadDataFromDisk(); if (server.ipfd_count > 0) redisLog(REDIS_NOTICE,"The server is now ready to accept connections on port %d", server.port); |