summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2013-12-23 22:01:53 +0100
committerGravatar Nikias Bassen2013-12-23 22:01:53 +0100
commiteb9415e18fda0bf394afe8439319a69bbcb196f4 (patch)
treed717eeb902d7b36704d24de2e32bd260bf6acad7
parent3d9687b71f73948319931943c75d28a61af36a31 (diff)
downloadusbmuxd-eb9415e18fda0bf394afe8439319a69bbcb196f4.tar.gz
usbmuxd-eb9415e18fda0bf394afe8439319a69bbcb196f4.tar.bz2
increase number of open file descriptors
When a large number of devices are used, the number of open file descriptors can reach the default system limit. Upon startup we now raise it to a much higher value to give more 'space'.
-rw-r--r--src/main.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index 9e2db60..350fae6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -37,6 +37,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include <sys/un.h>
#include <sys/stat.h>
#include <sys/types.h>
+#include <sys/resource.h>
#include <fcntl.h>
#include <getopt.h>
#include <pwd.h>
@@ -525,6 +526,12 @@ int main(int argc, char *argv[])
goto terminate;
}
+ // set number of file descriptors to higher value
+ struct rlimit rlim;
+ getrlimit(RLIMIT_NOFILE, &rlim);
+ rlim.rlim_max = 65536;
+ setrlimit(RLIMIT_NOFILE, (const struct rlimit*)&rlim);
+
usbmuxd_log(LL_INFO, "Creating socket");
res = listenfd = create_socket();
if(listenfd < 0)