#############################################################################*/
#include <arpa/inet.h>
+#include <errno.h>
#include <getopt.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+#include <sys/resource.h>
#include "client.h"
#include "main.h"
return 1;
}
+static int set_limits(struct fireperf_config* conf) {
+ struct rlimit limit;
+
+ // Increase limit of open files
+ limit.rlim_cur = limit.rlim_max = conf->parallel + 128;
+
+ int r = setrlimit(RLIMIT_NOFILE, &limit);
+ if (r) {
+ ERROR(conf, "Could not set open file limit to %lu: %s\n",
+ (unsigned long)limit.rlim_max, strerror(errno));
+ return 1;
+ }
+
+ return 0;
+}
+
static int parse_argv(int argc, char* argv[], struct fireperf_config* conf) {
static struct option long_options[] = {
{"client", required_argument, 0, 'c'},
DEBUG(&conf, "Configuration:\n");
DEBUG(&conf, " Port = %d\n", conf.port);
+ // Set limits
+ r = set_limits(&conf);
+ if (r)
+ return r;
+
switch (conf.mode) {
case FIREPERF_MODE_CLIENT:
return fireperf_client(&conf);