From 765317d54ec5658dd0c598170d0fc0824f751265 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 10 Mar 2011 15:13:31 +0100 Subject: improved tcpflood test tool to support many more connections even on platforms that place a low limit on the number of file descriptors per processes. The tool now increases the fd limit as required. --- tests/tcpflood.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/tcpflood.c') diff --git a/tests/tcpflood.c b/tests/tcpflood.c index d8c3f038..138706aa 100644 --- a/tests/tcpflood.c +++ b/tests/tcpflood.c @@ -62,6 +62,7 @@ #include #include #include +#include #define EXIT_FAILURE 1 #define INVALID_SOCKET -1 @@ -377,6 +378,7 @@ int main(int argc, char *argv[]) int ret = 0; int opt; struct sigaction sigAct; + struct rlimit maxFiles; static char buf[1024]; srand(time(NULL)); /* seed is good enough for our needs */ @@ -439,6 +441,18 @@ int main(int argc, char *argv[]) } } + if(numConnections > 100) { + maxFiles.rlim_cur = numConnections + 50; + maxFiles.rlim_max = numConnections + 50; + if(setrlimit(RLIMIT_NOFILE, &maxFiles) < 0) { + perror("set number of open files"); + fprintf(stderr, + "could net set sufficiently large number of " + "open files for required connection count!\n"); + exit(1); + } + } + if(dataFile != NULL) { if((dataFP = fopen(dataFile, "r")) == NULL) { perror(dataFile); -- cgit