aboutsummaryrefslogtreecommitdiff
path: root/perf
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-05-07 19:42:33 -0700
committerGarrett D'Amore <garrett@damore.org>2018-05-07 19:42:33 -0700
commitcc12510e510bc8e7f1b6d9e3816c6779caeee46c (patch)
tree4f8549c76418b8dd9b8126abfc3c6152a66e6541 /perf
parent9494ae2130d65df46a9c3e8dd8836dce07ade042 (diff)
downloadnng-cc12510e510bc8e7f1b6d9e3816c6779caeee46c.tar.gz
nng-cc12510e510bc8e7f1b6d9e3816c6779caeee46c.tar.bz2
nng-cc12510e510bc8e7f1b6d9e3816c6779caeee46c.zip
fixes #304 perf tool exits too quickly on throughput client
This adds a synchronization at exit step, where the server sends a completion message to the client. This permits the client to to be sure that the server has got all the data. There is a 5 second timeout, which should allow this to work (albeit with a weird 5 second completion delay) with legacy servers.
Diffstat (limited to 'perf')
-rw-r--r--perf/perf.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/perf/perf.c b/perf/perf.c
index 2002ad7f..6bf6a2aa 100644
--- a/perf/perf.c
+++ b/perf/perf.c
@@ -431,6 +431,10 @@ throughput_server(const char *addr, size_t msgsize, int count)
nng_msg_free(msg);
}
end = nng_clock();
+ // Send a synchronization message (empty) to the other side,
+ // and wait a bit to make sure it goes out the wire.
+ nng_send(s, "", 0, 0);
+ nng_msleep(200);
nng_close(s);
total = (float) ((end - start)) / 1000;
msgpersec = (float) (count) / total;
@@ -465,6 +469,11 @@ throughput_client(const char *addr, size_t msgsize, int count)
die("nng_setopt(nng_opt_sendbuf): %s", nng_strerror(rv));
}
+ rv = nng_setopt_ms(s, NNG_OPT_RECVTIMEO, 5000);
+ if (rv != 0) {
+ die("nng_setopt(nng_opt_recvtimeo): %s", nng_strerror(rv));
+ }
+
if ((rv = nng_dial(s, addr, NULL, 0)) != 0) {
die("nng_dial: %s", nng_strerror(rv));
}
@@ -486,7 +495,10 @@ throughput_client(const char *addr, size_t msgsize, int count)
}
}
- // Wait 100msec for pipes to drain.
- nng_msleep(100);
+ // Attempt to get the completion indication from the other side.
+ if (nng_recvmsg(s, &msg, 0) == 0) {
+ nng_msg_free(msg);
+ }
+
nng_close(s);
}