From 78b26d7ac259221ece1dad7faa1677bd01304a79 Mon Sep 17 00:00:00 2001 From: Jake Cobb Date: Thu, 10 Aug 2017 14:29:21 -0400 Subject: [PATCH] Problem: Throughput perf tool doesn't support CURVE Solution: Add extra argument to enable CURVE, use fixed keys to make local_thr and remote_thr compatible with CURVE enabled. --- perf/local_thr.cpp | 27 +++++++++++++++++++++++++-- perf/remote_thr.cpp | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/perf/local_thr.cpp b/perf/local_thr.cpp index bcef32e9..f924be24 100644 --- a/perf/local_thr.cpp +++ b/perf/local_thr.cpp @@ -31,6 +31,12 @@ #include #include +// keys are arbitrary but must match remote_lat.cpp +const char server_pubkey[] = "DX4nh=yUn{-9ugra0X3Src4SU-4xTgqxcYY.+ \n"); + if (argc != 4 && argc != 5) { + printf ("usage: local_thr []\n"); return 1; } bind_to = argv [1]; message_size = atoi (argv [2]); message_count = atoi (argv [3]); + if (argc >= 5 && atoi (argv [4])) { + curve = 1; + } ctx = zmq_init (1); if (!ctx) { @@ -68,6 +78,19 @@ int main (int argc, char *argv []) // Add your socket options here. // For example ZMQ_RATE, ZMQ_RECOVERY_IVL and ZMQ_MCAST_LOOP for PGM. + if (curve) { + rc = zmq_setsockopt (s, ZMQ_CURVE_SECRETKEY, server_prvkey, sizeof(server_prvkey)); + if (rc != 0) { + printf ("error in zmq_setsockoopt: %s\n", zmq_strerror (errno)); + return -1; + } + int server = 1; + rc = zmq_setsockopt (s, ZMQ_CURVE_SERVER, &server, sizeof(int)); + if (rc != 0) { + printf ("error in zmq_setsockoopt: %s\n", zmq_strerror (errno)); + return -1; + } + } rc = zmq_bind (s, bind_to); if (rc != 0) { diff --git a/perf/remote_thr.cpp b/perf/remote_thr.cpp index 3eaecd15..83729137 100644 --- a/perf/remote_thr.cpp +++ b/perf/remote_thr.cpp @@ -32,6 +32,12 @@ #include #include +// keys are arbitrary but must match local_lat.cpp +const char server_pubkey[] = "DX4nh=yUn{-9ugra0X3Src4SU-4xTgqxcYY.+ " - "\n"); + " []\n"); return 1; } connect_to = argv [1]; message_size = atoi (argv [2]); message_count = atoi (argv [3]); + if (argc >= 5 && atoi (argv [4])) { + curve = 1; + } ctx = zmq_init (1); if (!ctx) { @@ -66,6 +76,25 @@ int main (int argc, char *argv []) // Add your socket options here. // For example ZMQ_RATE, ZMQ_RECOVERY_IVL and ZMQ_MCAST_LOOP for PGM. + if (curve) { + rc = zmq_setsockopt (s, ZMQ_CURVE_SECRETKEY, client_prvkey, sizeof (client_prvkey)); + if (rc != 0) { + printf ("error in zmq_setsockoopt: %s\n", zmq_strerror (errno)); + return -1; + } + + rc = zmq_setsockopt (s, ZMQ_CURVE_PUBLICKEY, client_pubkey, sizeof (client_pubkey)); + if (rc != 0) { + printf ("error in zmq_setsockoopt: %s\n", zmq_strerror (errno)); + return -1; + } + + rc = zmq_setsockopt (s, ZMQ_CURVE_SERVERKEY, server_pubkey, sizeof (server_pubkey)); + if (rc != 0) { + printf ("error in zmq_setsockoopt: %s\n", zmq_strerror (errno)); + return -1; + } + } rc = zmq_connect (s, connect_to); if (rc != 0) {