summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/tcpflood.c14
1 files changed, 14 insertions, 0 deletions
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 <unistd.h>
#include <string.h>
#include <netinet/in.h>
+#include <sys/resource.h>
#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);