summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorflaviojs <flaviojs@54d463be-8e91-2dee-dedb-b68131a5f0ec>2011-07-15 06:16:51 +0000
committerflaviojs <flaviojs@54d463be-8e91-2dee-dedb-b68131a5f0ec>2011-07-15 06:16:51 +0000
commit14fbb28bad5ae22f495766a449aea8aac7431c40 (patch)
treeed276a13f2402dbf2fc57e4b6ba8826a01d679bc
parent644fab2943d84e4225825996bdbbac4a91bdd6b9 (diff)
downloadhercules-14fbb28bad5ae22f495766a449aea8aac7431c40.tar.gz
hercules-14fbb28bad5ae22f495766a449aea8aac7431c40.tar.bz2
hercules-14fbb28bad5ae22f495766a449aea8aac7431c40.tar.xz
hercules-14fbb28bad5ae22f495766a449aea8aac7431c40.zip
* Changed the warning message of when setrlimit fails to be more explicit.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14907 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--Changelog-Trunk.txt2
-rw-r--r--src/common/socket.c11
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);
}
}
}