diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-08-24 14:15:48 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-08-24 14:20:34 -0700 |
| commit | c9a68bfe6bea2acc708bf49045f6cb65017a3306 (patch) | |
| tree | e2b93b81b2962bdfb7953cb30fcfae08f0bd4093 /tests/scalability.c | |
| parent | 68ff9c823d3cead2b11a003c40c8f5affc11dc71 (diff) | |
| download | nng-c9a68bfe6bea2acc708bf49045f6cb65017a3306.tar.gz nng-c9a68bfe6bea2acc708bf49045f6cb65017a3306.tar.bz2 nng-c9a68bfe6bea2acc708bf49045f6cb65017a3306.zip | |
Eliminate legacy option settings, provide easier option IDs.
This eliminates all the old #define's or enum values, making all
option IDs now totally dynamic, and providing well-known string
values for well-behaved applications.
We have added tests of some of these options, including lookups, and
so forth. We have also fixed a few problems; including at least
one crasher bug when the timeouts on reconnect were zero.
Protocol specific options are now handled in the protocol. We will
be moving the initialization for a few of those well known entities
to the protocol startup code, following the PAIRv1 pattern, later.
Applications must therefore not depend on the value of the integer IDs,
at least until the application has opened a socket of the appropriate
type.
Diffstat (limited to 'tests/scalability.c')
| -rw-r--r-- | tests/scalability.c | 51 |
1 files changed, 14 insertions, 37 deletions
diff --git a/tests/scalability.c b/tests/scalability.c index 0bb93401..f0fc6366 100644 --- a/tests/scalability.c +++ b/tests/scalability.c @@ -52,29 +52,15 @@ openclients(nng_socket *clients, int num) int i; uint64_t t; for (i = 0; i < num; i++) { - if ((rv = nng_req_open(&clients[i])) != 0) { - printf("open #%d: %s\n", i, nng_strerror(rv)); - return (rv); - } - t = 100000; // 100ms - rv = nng_setopt(clients[i], NNG_OPT_RCVTIMEO, &t, sizeof(t)); - if (rv != 0) { - printf( - "setopt(RCVTIMEO) #%d: %s\n", i, nng_strerror(rv)); - return (rv); - } - t = 100000; // 100ms - rv = nng_setopt(clients[i], NNG_OPT_SNDTIMEO, &t, sizeof(t)); - if (rv != 0) { - printf( - "setopt(SNDTIMEO) #%d: %s\n", i, nng_strerror(rv)); - return (rv); - } - rv = nng_dial(clients[i], addr, NULL, 0); - if (rv != 0) { - printf("dial #%d: %s\n", i, nng_strerror(rv)); + t = 100000; // 100ms + nng_socket c; + if (((rv = nng_req_open(&c)) != 0) || + ((rv = nng_setopt_usec(c, nng_optid_recvtimeo, t)) != 0) || + ((rv = nng_setopt_usec(c, nng_optid_sendtimeo, t)) != 0) || + ((rv = nng_dial(c, addr, NULL, 0)) != 0)) { return (rv); } + clients[i] = c; } return (0); } @@ -88,31 +74,22 @@ transact(nng_socket *clients, int num) for (i = 0; i < num; i++) { - if ((rv = nng_msg_alloc(&msg, 0)) != 0) { - break; - } - - if ((rv = nng_sendmsg(clients[i], msg, 0)) != 0) { - break; - } - - msg = NULL; - if ((rv = nng_recvmsg(clients[i], &msg, 0)) != 0) { + if (((rv = nng_msg_alloc(&msg, 0)) != 0) || + ((rv = nng_sendmsg(clients[i], msg, 0)) != 0) || + ((rv = nng_recvmsg(clients[i], &msg, 0)) != 0)) { + // We may leak a message, but this is an + // error case anyway. break; } nng_msg_free(msg); msg = NULL; } - if (msg != NULL) { - nng_msg_free(msg); - } return (rv); } Main({ nng_socket *clients; int * results; - int depth = 256; atexit(stop); @@ -120,8 +97,8 @@ Main({ results = calloc(nclients, sizeof(int)); if ((nng_rep_open(&rep) != 0) || - (nng_setopt(rep, NNG_OPT_RCVBUF, &depth, sizeof(depth)) != 0) || - (nng_setopt(rep, NNG_OPT_SNDBUF, &depth, sizeof(depth)) != 0) || + (nng_setopt_int(rep, nng_optid_recvbuf, 256) != 0) || + (nng_setopt_int(rep, nng_optid_sendbuf, 256) != 0) || (nng_listen(rep, addr, NULL, 0) != 0) || (nng_thread_create(&server, serve, NULL) != 0)) { fprintf(stderr, "Unable to set up server!\n"); |
