summaryrefslogtreecommitdiff
path: root/src/common/socket.c
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 /src/common/socket.c
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
Diffstat (limited to 'src/common/socket.c')
-rw-r--r--src/common/socket.c11
1 files changed, 9 insertions, 2 deletions
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);
}
}
}