diff options
-rw-r--r-- | Changelog-Trunk.txt | 2 | ||||
-rw-r--r-- | src/common/socket.c | 11 |
2 files changed, 11 insertions, 2 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 3d5d32577..107bc61de 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -1,5 +1,7 @@ Date Added +2011/07/15 + * Changed the warning message of when setrlimit fails to be more explicit. [FlavioJS] 2011/07/12 * CMake: set project language to C, added module FindFunctionLibrary, added search for dl library. (tested with debian-wheezy-i386) [FlavioJS] * CMake: added search for math.h, added search for socket/nsl library. (tested with Solaris-201011-x86) diff --git a/src/common/socket.c b/src/common/socket.c index 84cbaf1ea..81e5a7bd2 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -1248,16 +1248,23 @@ void socket_init(void) rlp.rlim_cur = FD_SETSIZE; if( 0 != setrlimit(RLIMIT_NOFILE, &rlp) ) {// failed, try setting the maximum too (permission to change system limits is required) + int err; rlp.rlim_max = FD_SETSIZE; - if( 0 != setrlimit(RLIMIT_NOFILE, &rlp) ) + err = setrlimit(RLIMIT_NOFILE, &rlp); + if( err != 0 ) {// failed + const char* errmsg = "unknown"; + int rlim_ori; // set to maximum allowed getrlimit(RLIMIT_NOFILE, &rlp); + rlim_ori = (int)rlp.rlim_cur; rlp.rlim_cur = rlp.rlim_max; setrlimit(RLIMIT_NOFILE, &rlp); // report limit getrlimit(RLIMIT_NOFILE, &rlp); - ShowWarning("socket_init: failed to set socket limit to %d (current limit %d).\n", FD_SETSIZE, (int)rlp.rlim_cur); + if( err == EPERM ) + errmsg = "permission denied"; + ShowWarning("socket_init: failed to set socket limit to %d, setting to maximum allowed (original limit=%d, current limit=%d, maximum allowed=%d, error=%s).\n", FD_SETSIZE, rlim_ori, (int)rlp.rlim_cur, (int)rlp.rlim_max, errmsg); } } } |