summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2011-03-10 15:13:31 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2011-03-10 15:13:31 +0100
commit765317d54ec5658dd0c598170d0fc0824f751265 (patch)
tree6dda22325b4193ef0111468536ea520e0178d128 /tests
parentc1760db6bbd07086177679b2be4b2d307657ddce (diff)
downloadrsyslog-765317d54ec5658dd0c598170d0fc0824f751265.tar.gz
rsyslog-765317d54ec5658dd0c598170d0fc0824f751265.tar.xz
rsyslog-765317d54ec5658dd0c598170d0fc0824f751265.zip
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.
Diffstat (limited to 'tests')
-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);