From a2c4e6e95f61b28f0d59b90ad8e5567e4dccfd33 Mon Sep 17 00:00:00 2001 From: gepard1984 Date: Mon, 13 Feb 2012 20:17:45 +0000 Subject: Socket init now gives meaningful error description if failed to set socket limit (tid:58887). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15574 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/socket.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/common/socket.c b/src/common/socket.c index ce9f7db22..592755d5a 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -1280,12 +1280,10 @@ 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; - err = setrlimit(RLIMIT_NOFILE, &rlp); - if( err != 0 ) + if( 0 != setrlimit(RLIMIT_NOFILE, &rlp) ) {// failed - const char* errmsg = "unknown"; + const char *errmsg = error_msg(); int rlim_ori; // set to maximum allowed getrlimit(RLIMIT_NOFILE, &rlp); @@ -1294,10 +1292,8 @@ void socket_init(void) setrlimit(RLIMIT_NOFILE, &rlp); // report limit getrlimit(RLIMIT_NOFILE, &rlp); - 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); rlim_cur = rlp.rlim_cur; + ShowWarning("socket_init: failed to set socket limit to %d, setting to maximum allowed (original limit=%d, current limit=%d, maximum allowed=%d, %s).\n", FD_SETSIZE, rlim_ori, (int)rlp.rlim_cur, (int)rlp.rlim_max, errmsg); } } } -- cgit v1.2.3-70-g09d2