]> git.ipfire.org Git - fireperf.git/commitdiff
client: ALlow keepalive only mode
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 28 Jan 2021 11:28:55 +0000 (11:28 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 28 Jan 2021 11:28:55 +0000 (11:28 +0000)
In this mode, the client won't send any data and only hold the
connections open.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/client.c
src/main.c
src/main.h

index cc9fd4470a29cfe730d2274925c1bdda2c154435..87026c9ba992c4a2eb13c305ae4fc6c6a2dadbfd 100644 (file)
@@ -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);
 
index a1fc96ad2979b997170c35054d9845687634e06a..77cad48112e04a117e980484506723310c82b10c 100644 (file)
@@ -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);
 
index b5eed86f77d97c1e317acae8a5d87a8ccbf65473..9c5a396fb5c36825d2d6003c2623727c4ebc2672 100644 (file)
@@ -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;