summaryrefslogtreecommitdiff
path: root/src/common/socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/socket.c')
-rw-r--r--src/common/socket.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/common/socket.c b/src/common/socket.c
index 9b48f0401..7addc271b 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -32,6 +32,10 @@
#ifndef SIOCGIFCONF
#include <sys/sockio.h> // SIOCGIFCONF on Solaris, maybe others? [Shinomori]
#endif
+
+ #ifdef HAVE_SETRLIMIT
+ #include <sys/resource.h>
+ #endif
#endif
/////////////////////////////////////////////////////////////////////
@@ -1200,6 +1204,23 @@ void socket_init(void)
return;
}
}
+#elif defined(HAVE_SETRLIMIT)
+ {// set socket limit to FD_SETSIZE
+ struct rlimit rlp;
+ if( 0 == getrlimit(RLIMIT_NOFILE, &rlp) )
+ {
+ rlp.rlim_cur = FD_SETSIZE;
+ if( 0 != setrlimit(RLIMIT_NOFILE, &rlp) )
+ {// failed, try setting the maximum too (permission to change system limits is required)
+ rlp.rlim_max = FD_SETSIZE;
+ if( 0 != setrlimit(RLIMIT_NOFILE, &rlp) )
+ {// failed
+ getrlimit(RLIMIT_NOFILE, &rlp);
+ ShowWarning("socket_init: %s - failed to set socket limit to %d (current limit %d).\n", strerror(errno), FD_SETSIZE, (int)rlp.rlim_cur);
+ }
+ }
+ }
+ }
#endif
// Get initial local ips