From 9a43cc6e6b61d16c157d53ab7f22a34ae61a9bc4 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Sat, 27 Aug 2016 06:58:55 +0800 Subject: [PATCH] Fix #781 --- src/local.c | 23 +++++++++++++---------- src/redir.c | 23 +++++++++++++---------- src/server.c | 23 +++++++++++++---------- src/tunnel.c | 23 +++++++++++++---------- 4 files changed, 52 insertions(+), 40 deletions(-) diff --git a/src/local.c b/src/local.c index 7018eb9f..b2b949d0 100644 --- a/src/local.c +++ b/src/local.c @@ -1181,16 +1181,6 @@ int main(int argc, char **argv) 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 > 1024) { - if (verbose) { - LOGI("setting NOFILE to %d", nofile); - } - set_nofile(nofile); - } #endif } @@ -1204,6 +1194,19 @@ int main(int argc, char **argv) timeout = "60"; } +#ifdef HAVE_SETRLIMIT + /* + * no need to check the return value here since we will show + * the user an error message if setrlimit(2) fails + */ + if (nofile > 1024) { + if (verbose) { + LOGI("setting NOFILE to %d", nofile); + } + set_nofile(nofile); + } +#endif + if (local_addr == NULL) { local_addr = "127.0.0.1"; } diff --git a/src/redir.c b/src/redir.c index b775d858..983e5551 100644 --- a/src/redir.c +++ b/src/redir.c @@ -844,16 +844,6 @@ int main(int argc, char **argv) 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 > 1024) { - if (verbose) { - LOGI("setting NOFILE to %d", nofile); - } - set_nofile(nofile); - } #endif } @@ -867,6 +857,19 @@ int main(int argc, char **argv) timeout = "60"; } +#ifdef HAVE_SETRLIMIT + /* + * no need to check the return value here since we will show + * the user an error message if setrlimit(2) fails + */ + if (nofile > 1024) { + if (verbose) { + LOGI("setting NOFILE to %d", nofile); + } + set_nofile(nofile); + } +#endif + if (local_addr == NULL) { local_addr = "127.0.0.1"; } diff --git a/src/server.c b/src/server.c index 3e34ab24..4089f07f 100644 --- a/src/server.c +++ b/src/server.c @@ -1603,16 +1603,6 @@ int main(int argc, char **argv) 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 > 1024) { - if (verbose) { - LOGI("setting NOFILE to %d", nofile); - } - set_nofile(nofile); - } #endif if (conf->nameserver != NULL) { nameservers[nameserver_num++] = conf->nameserver; @@ -1636,6 +1626,19 @@ int main(int argc, char **argv) timeout = "60"; } +#ifdef HAVE_SETRLIMIT + /* + * no need to check the return value here since we will show + * the user an error message if setrlimit(2) fails + */ + if (nofile > 1024) { + if (verbose) { + LOGI("setting NOFILE to %d", nofile); + } + set_nofile(nofile); + } +#endif + if (pid_flags) { USE_SYSLOG(argv[0]); daemonize(pid_path); diff --git a/src/tunnel.c b/src/tunnel.c index 329cb9e2..4858e092 100644 --- a/src/tunnel.c +++ b/src/tunnel.c @@ -890,16 +890,6 @@ int main(int argc, char **argv) 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 > 1024) { - if (verbose) { - LOGI("setting NOFILE to %d", nofile); - } - set_nofile(nofile); - } #endif } @@ -913,6 +903,19 @@ int main(int argc, char **argv) timeout = "60"; } +#ifdef HAVE_SETRLIMIT + /* + * no need to check the return value here since we will show + * the user an error message if setrlimit(2) fails + */ + if (nofile > 1024) { + if (verbose) { + LOGI("setting NOFILE to %d", nofile); + } + set_nofile(nofile); + } +#endif + if (local_addr == NULL) { local_addr = "127.0.0.1"; }