]> git.ipfire.org Git - fireperf.git/commitdiff
server: Support "--close"
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 18 Feb 2021 16:51:13 +0000 (16:51 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 18 Feb 2021 16:51:13 +0000 (16:51 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
man/fireperf.txt
src/client.c
src/server.c

index fa100f042a115be70dc4a047fa8f2c28fe40bd6b..c519361c23f2792311fdd160a7ea1eccbfd0789b 100644 (file)
@@ -45,6 +45,13 @@ a network between a fireperf client and fireperf server.
 -V::
        Prints the version of this program
 
+--close::
+-x::
+       If set, all connections will be closed as soon as they have been established.
+       No data will be sent.
+       +
+       This is useful to test how many TCP handshakes per second are possible.
+
 --zero::
 -z::
        Instead of sending random data, this option will set the client to send packets
@@ -87,13 +94,6 @@ a network between a fireperf client and fireperf server.
        If set, the client will automatically terminate itself after T seconds.
        Otherwise it will run for forever.
 
---close::
--x::
-       If set, all connections will be closed as soon as they have been established.
-       No data will be sent.
-       +
-       This is useful to test how many TCP handshakes per second are possible.
-
 
 == BUGS
 Please report all bugs to the bugtracker at https://bugzilla.ipfire.org/
index 48b377a44af8dd55263af676038061c8e061db56..aae4b8e22d1af7fc3cd3eaa6eb47a7d2c83a4fe5 100644 (file)
@@ -135,21 +135,6 @@ ERROR:
        return -1;
 }
 
-static int handle_connection_ready(struct fireperf_config* conf,
-               struct fireperf_stats* stats, int fd) {
-       // Are we supposed to close this connection straight away?
-       if (conf->close) {
-               DEBUG(conf, "Closing connection %d\n", fd);
-               close(fd);
-
-               stats->open_connections--;
-
-               return 0;
-       }
-
-       return handle_connection_send(conf, stats, fd);
-}
-
 int fireperf_client(struct fireperf_config* conf, struct fireperf_stats* stats,
                int epollfd, int timerfd) {
        DEBUG(conf, "Launching " PACKAGE_NAME " in client mode\n");
@@ -244,6 +229,15 @@ int fireperf_client(struct fireperf_config* conf, struct fireperf_stats* stats,
 
                                        stats->open_connections--;
                                } else {
+                                       // Close connections immediately when -x is set
+                                       if (conf->close) {
+                                               DEBUG(conf, "Closing connection %d\n", fd);
+                                               close(fd);
+
+                                               stats->open_connections--;
+                                               continue;
+                                       }
+
                                        // Handle incoming data
                                        if (events[i].events & EPOLLIN) {
                                                r = handle_connection_recv(conf, stats, fd);
@@ -253,7 +247,7 @@ int fireperf_client(struct fireperf_config* conf, struct fireperf_stats* stats,
 
                                        // Handle outgoing data
                                        if (events[i].events & EPOLLOUT) {
-                                               r = handle_connection_ready(conf, stats, fd);
+                                               r = handle_connection_send(conf, stats, fd);
                                                if (r)
                                                        goto ERROR;
                                        }
index 52a09a69f342c586e6863d61d740de539b665ca7..6b21f5d274dfd0f550119811964d28caf21b90be 100644 (file)
@@ -220,6 +220,15 @@ int fireperf_server(struct fireperf_config* conf, struct fireperf_stats* stats,
                                        continue;
                                }
 
+                               // Close connections immediately when -x is set
+                               if (conf->close) {
+                                       DEBUG(conf, "Closing connection %d\n", fd);
+                                       close(fd);
+
+                                       stats->open_connections--;
+                                       continue;
+                               }
+
                                // Handle incoming data
                                if (events[i].events & EPOLLIN) {
                                        r = handle_connection_recv(conf, stats, fd);