Added support for setrlimit(2)

This commit is contained in:
Datong Sun
2014-07-14 01:49:24 -05:00
parent 0017b7c198
commit 1d8719f2e4
9 changed files with 87 additions and 2 deletions
+18
View File
@@ -67,6 +67,9 @@ int udprelay = 0;
#ifdef TCP_FASTOPEN
static int fast_open = 0;
#endif
#ifdef HAVE_SETRLIMIT
static int nofile = 0;
#endif
static int remote_conn = 0;
static int server_conn = 0;
@@ -1048,6 +1051,21 @@ int main (int argc, char **argv)
if (timeout == NULL) timeout = conf->timeout;
#ifdef TCP_FASTOPEN
if (fast_open == 0) fast_open = conf->fast_open;
#endif
#ifdef HAVE_SETRLIMIT
if (nofile == 0) nofile = conf->nofile;
/*
* no need to check the return value here since we will show
* the user an error message if setrlimit(2) fails
*/
if (nofile)
{
if (verbose)
{
LOGD("setting NOFILE to %d", nofile);
}
set_nofile(nofile);
}
#endif
}