From: Michael Tremer Date: Thu, 28 Jan 2021 11:28:55 +0000 (+0000) Subject: client: ALlow keepalive only mode X-Git-Tag: 0.1.0~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=79a2c4d724346d89e71eeab82df83b36214a59b1;p=fireperf.git client: ALlow keepalive only mode In this mode, the client won't send any data and only hold the connections open. Signed-off-by: Michael Tremer --- diff --git a/src/client.c b/src/client.c index cc9fd44..87026c9 100644 --- a/src/client.c +++ b/src/client.c @@ -120,7 +120,11 @@ int fireperf_client(struct fireperf_config* conf) { return 1; } - ev.events = EPOLLIN|EPOLLOUT; + ev.events = EPOLLIN; + + // Let us know when the socket is ready for sending data + if (!conf->keepalive_only) + ev.events |= EPOLLOUT; DEBUG(conf, "Opening %lu connections...\n", conf->parallel); diff --git a/src/main.c b/src/main.c index a1fc96a..77cad48 100644 --- a/src/main.c +++ b/src/main.c @@ -58,6 +58,7 @@ static int parse_argv(int argc, char* argv[], struct fireperf_config* conf) { static struct option long_options[] = { {"client", required_argument, 0, 'c'}, {"debug", no_argument, 0, 'd'}, + {"keepalive", no_argument, 0, 'k'}, {"parallel", required_argument, 0, 'P'}, {"port", required_argument, 0, 'p'}, {"server", no_argument, 0, 's'}, @@ -70,7 +71,7 @@ static int parse_argv(int argc, char* argv[], struct fireperf_config* conf) { int done = 0; while (!done) { - int c = getopt_long(argc, argv, "c:dp:st:zP:", long_options, &option_index); + int c = getopt_long(argc, argv, "c:dkp:st:zP:", long_options, &option_index); // End if (c == -1) @@ -108,6 +109,10 @@ static int parse_argv(int argc, char* argv[], struct fireperf_config* conf) { conf->loglevel = LOG_DEBUG; break; + case 'k': + conf->keepalive_only = 1; + break; + case 'P': conf->parallel = strtoul(optarg, NULL, 10); diff --git a/src/main.h b/src/main.h index b5eed86..9c5a396 100644 --- a/src/main.h +++ b/src/main.h @@ -44,6 +44,7 @@ struct fireperf_config { FIREPERF_MODE_SERVER, } mode; struct in6_addr address; + int keepalive_only; int port; unsigned long parallel; unsigned int timeout;