Commit 7c671c09 authored by antirez's avatar antirez
Browse files

Check that tcp-backlog is matched by /proc/sys/net/core/somaxconn.

parent d56ef629
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#define HAVE_PROC_STAT 1 #define HAVE_PROC_STAT 1
#define HAVE_PROC_MAPS 1 #define HAVE_PROC_MAPS 1
#define HAVE_PROC_SMAPS 1 #define HAVE_PROC_SMAPS 1
#define HAVE_PROC_SOMAXCONN 1
#endif #endif
/* Test for task_info() */ /* Test for task_info() */
......
...@@ -1535,6 +1535,23 @@ void adjustOpenFilesLimit(void) { ...@@ -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' /* Initialize a set of file descriptors to listen to the specified 'port'
* binding the addresses specified in the Redis server configuration. * binding the addresses specified in the Redis server configuration.
* *
...@@ -3346,6 +3363,7 @@ int main(int argc, char **argv) { ...@@ -3346,6 +3363,7 @@ int main(int argc, char **argv) {
#ifdef __linux__ #ifdef __linux__
linuxMemoryWarnings(); linuxMemoryWarnings();
#endif #endif
checkTcpBacklogSettings();
loadDataFromDisk(); loadDataFromDisk();
if (server.ipfd_count > 0) if (server.ipfd_count > 0)
redisLog(REDIS_NOTICE,"The server is now ready to accept connections on port %d", server.port); redisLog(REDIS_NOTICE,"The server is now ready to accept connections on port %d", server.port);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment