diff options
| author | Garrett D'Amore <garrett@damore.org> | 2021-11-28 09:05:30 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2021-11-28 18:13:21 -0800 |
| commit | efa702387fcfa80ddd02e1a85f73c5b6f6ba1955 (patch) | |
| tree | 853d84a55f7b4f9c1c100a82443520a258cec9d8 | |
| parent | 774e9375153d8a48bd1cbf654ca323656551b054 (diff) | |
| download | nng-efa702387fcfa80ddd02e1a85f73c5b6f6ba1955.tar.gz nng-efa702387fcfa80ddd02e1a85f73c5b6f6ba1955.tar.bz2 nng-efa702387fcfa80ddd02e1a85f73c5b6f6ba1955.zip | |
fixes #1536 nng_sendmsg and nng_recvmsg could be faster
fixes #1535 Desire nng_ctx_sendmsg and nng_ctx_recvmsg
| -rw-r--r-- | docs/man/libnng.3.adoc | 5 | ||||
| -rw-r--r-- | docs/man/nng_ctx.5.adoc | 2 | ||||
| -rw-r--r-- | docs/man/nng_ctx_recvmsg.3.adoc | 63 | ||||
| -rw-r--r-- | docs/man/nng_ctx_sendmsg.3.adoc | 84 | ||||
| -rw-r--r-- | docs/man/nng_recvmsg.3.adoc | 5 | ||||
| -rw-r--r-- | include/nng/nng.h | 14 | ||||
| -rw-r--r-- | src/nng.c | 140 | ||||
| -rw-r--r-- | src/sp/protocol/survey0/survey_test.c | 63 |
8 files changed, 325 insertions, 51 deletions
diff --git a/docs/man/libnng.3.adoc b/docs/man/libnng.3.adoc index 712bf0fb..7475cdca 100644 --- a/docs/man/libnng.3.adoc +++ b/docs/man/libnng.3.adoc @@ -1,6 +1,6 @@ = libnng(3) // -// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // Copyright 2019 Devolutions <info@devolutions.net> // Copyright 2020 Dirac Research <robert.bielik@dirac.com> @@ -231,7 +231,10 @@ concurrent applications. |xref:nng_ctx_id.3.adoc[nng_ctx_id()]|get numeric context identifier |xref:nng_ctx_open.3.adoc[nng_ctx_open()]|create context |xref:nng_ctx_recv.3.adoc[nng_ctx_recv()]|receive message using context asynchronously +|xref:nng_ctx_recvmsg.3.adoc[nng_ctx_recvmsg()]|receive a message using context |xref:nng_ctx_send.3.adoc[nng_ctx_send()]|send message using context asynchronously +|xref:nng_ctx_sendmsg.3.adoc[nng_ctx_sendmsg()]|send a message using context + |xref:nng_ctx_set.3.adoc[nng_ctx_set()]|set context option |xref:nng_ctx_setopt.3.adoc[nng_ctx_setopt()]|set context option |=== diff --git a/docs/man/nng_ctx.5.adoc b/docs/man/nng_ctx.5.adoc index cc859c48..c8ab62cd 100644 --- a/docs/man/nng_ctx.5.adoc +++ b/docs/man/nng_ctx.5.adoc @@ -165,7 +165,9 @@ xref:nng_ctx_open.3.adoc[nng_ctx_open(3)], xref:nng_ctx_get.3.adoc[nng_ctx_get(3)], xref:nng_ctx_id.3.adoc[nng_ctx_id(3)], xref:nng_ctx_recv.3.adoc[nng_ctx_recv(3)], +xref:nng_ctx_recvmsg.3.adoc[nng_ctx_recvmsg(3)], xref:nng_ctx_send.3.adoc[nng_ctx_send(3)], +xref:nng_ctx_sendmsg.3.adoc[nng_ctx_sendmsg(3)], xref:nng_ctx_set.3.adoc[nng_ctx_set(3)], xref:nng_dialer.5.adoc[nng_dialer(5)], xref:nng_listener.5.adoc[nng_listener(5)], diff --git a/docs/man/nng_ctx_recvmsg.3.adoc b/docs/man/nng_ctx_recvmsg.3.adoc new file mode 100644 index 00000000..9651c34c --- /dev/null +++ b/docs/man/nng_ctx_recvmsg.3.adoc @@ -0,0 +1,63 @@ += nng_ctx_recvmsg(3) +// +// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech> +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_ctx_recvmsg - receive message using socket + +== SYNOPSIS + +[source, c] +---- +#include <nng/nng.h> + +int nng_ctx_recvmsg(nng_ctx ctx, nng_msg **msgp, int flags); +---- + +== DESCRIPTION + +The `nng_ctx_recvmsg()` receives a message on context _ctx_, storing the +received message at the location pointed to by _msgp_. + +The _flags_ may contain the following value: + +`NNG_FLAG_NONBLOCK`:: + The function returns immediately, even if no message is available. + Without this flag, the function will wait until a message is receivable + on the context _ctx_, or any configured timer expires. + +NOTE: The semantics of what receiving a message means vary from protocol to +protocol, so examination of the protocol documentation is encouraged. + +== RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +== ERRORS + +[horizontal] +`NNG_EAGAIN`:: The operation would block, but `NNG_FLAG_NONBLOCK` was specified. +`NNG_ECLOSED`:: The context or socket is not open. +`NNG_EINVAL`:: An invalid set of _flags_ was specified. +`NNG_ENOMEM`:: Insufficient memory is available. +`NNG_ENOTSUP`:: The protocol does not support receiving. +`NNG_ESTATE`:: The context cannot receive data in this state. +`NNG_ETIMEDOUT`:: The operation timed out. + +== SEE ALSO + +[.text-left] +xref:nng_msg_free.3.adoc[nng_msg_free(3)], +xref:nng_ctx_open.3.adoc[nng_ctx_open(3)], +xref:nng_ctx_recv.3.adoc[nng_ctx_recv(3)], +xref:nng_ctx_sendmsg.3.adoc[nng_ctx_sendmsg(3)], +xref:nng_strerror.3.adoc[nng_strerror(3)], +xref:nng_ctx.5.adoc[nng_ctx(5)], +xref:nng.7.adoc[nng(7)] diff --git a/docs/man/nng_ctx_sendmsg.3.adoc b/docs/man/nng_ctx_sendmsg.3.adoc new file mode 100644 index 00000000..8e2c97f4 --- /dev/null +++ b/docs/man/nng_ctx_sendmsg.3.adoc @@ -0,0 +1,84 @@ += nng_ctx_sendmsg(3) +// +// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech> +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_ctx_sendmsg - send message using context + +== SYNOPSIS + +[source, c] +---- +#include <nng/nng.h> + +int nng_ctx_sendmsg(nng_ctx c, nng_msg *msg, int flags); +---- + +== DESCRIPTION + +The `nng_ctx_sendmsg()` sends message _msg_ using the context _ctx_. + +If the function returns zero, indicating it has accepted the message for +delivery, then the _msg_ is owned by the socket _s_, and the caller +must not make any further use of it. +The socket will free the message when it is finished. + +If the function returns non-zero, then it is the caller's responsibility +to dispose of the _msg_, which may include freeing it, sending it to +another socket, or simply trying again later. + +NOTE: The semantics of what sending a message means vary from protocol to +protocol, so examination of the protocol documentation is encouraged. + +The _flags_ may contain the following value: + +`NNG_FLAG_NONBLOCK`:: + The function returns immediately, regardless of whether + the context is able to accept the data or not. + If the context is unable to accept the data (such as if backpressure exists + because the peers are consuming messages too slowly, or no peer is present), + then the function will return with `NNG_EAGAIN`. + If this flag is not specified, then the function will block if such a + condition exists. + + +NOTE: Regardless of the presence or absence of `NNG_FLAG_NONBLOCK`, there may +be queues between the sender and the receiver. +Furthermore, there is no guarantee that the message has actually been delivered. +Finally, with some protocols, the semantic is implicitly `NNG_FLAG_NONBLOCK`. + +== RETURN VALUES + +This function returns 0 on success, and non-zero otherwise. + +== ERRORS + +[horizontal] +`NNG_EAGAIN`:: The operation would block, but `NNG_FLAG_NONBLOCK` was specified. +`NNG_ECLOSED`:: The context or socket is not open. +`NNG_EINVAL`:: An invalid set of _flags_ was specified. +`NNG_EMSGSIZE`:: The value of _size_ is too large. +`NNG_ENOMEM`:: Insufficient memory is available. +`NNG_ENOTSUP`:: The protocol does not support sending. +`NNG_ESTATE`:: The context cannot send data in this state. +`NNG_ETIMEDOUT`:: The operation timed out. + +== SEE ALSO + +[.text-left] +xref:nng_msg_alloc.3.adoc[nng_msg_alloc(3)], +xref:nng_ctx_open.3.adoc[nng_ctx_open(3)], +xref:nng_ctx_recvmsg.3.adoc[nng_ctx_recvmsg(3)], +xref:nng_ctx_send.3.adoc[nng_ctx_send(3)], +xref:nng_sendmsg.3.adoc[nng_sendmsg(3)], +xref:nng_strerror.3.adoc[nng_strerror(3)], +xref:nng_msg.5.adoc[nng_msg(5)], +xref:nng_ctx.5.adoc[nng_ctx(5)], +xref:nng.7.adoc[nng(7)] diff --git a/docs/man/nng_recvmsg.3.adoc b/docs/man/nng_recvmsg.3.adoc index 6f1fcea9..c502d650 100644 --- a/docs/man/nng_recvmsg.3.adoc +++ b/docs/man/nng_recvmsg.3.adoc @@ -1,6 +1,6 @@ = nng_recvmsg(3) // -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // // This document is supplied under the terms of the MIT License, a @@ -11,7 +11,7 @@ == NAME -nng_recvmsg - recv message +nng_recvmsg - receive a message == SYNOPSIS @@ -67,4 +67,5 @@ xref:nng_msg_free.3.adoc[nng_msg_free(3)], xref:nng_recv.3.adoc[nng_recv(3)], xref:nng_sendmsg.3.adoc[nng_sendmsg(3)], xref:nng_strerror.3.adoc[nng_strerror(3)], +xref:nng_socket.5.adoc[nng_socket(5)], xref:nng.7.adoc[nng(7)] diff --git a/include/nng/nng.h b/include/nng/nng.h index cd75495a..a7c184ba 100644 --- a/include/nng/nng.h +++ b/include/nng/nng.h @@ -49,8 +49,8 @@ extern "C" { // We use SemVer, and these versions are about the API, and // may not necessarily match the ABI versions. #define NNG_MAJOR_VERSION 1 -#define NNG_MINOR_VERSION 5 -#define NNG_PATCH_VERSION 2 +#define NNG_MINOR_VERSION 6 +#define NNG_PATCH_VERSION 0 #define NNG_RELEASE_SUFFIX "" // if non-empty, this is a pre-release // Maximum length of a socket address. This includes the terminating NUL. @@ -421,10 +421,20 @@ NNG_DECL int nng_ctx_id(nng_ctx); // uses a local context instead of the socket global context. NNG_DECL void nng_ctx_recv(nng_ctx, nng_aio *); +// nng_ctx_recvmsg is allows for receiving a message synchronously using +// a context. It has the same semantics as nng_recvmsg, but operates +// on a context instead of a socket. +NNG_DECL int nng_ctx_recvmsg(nng_ctx, nng_msg **, int); + // nng_ctx_send sends asynchronously. It works like nng_send_aio, but // uses a local context instead of the socket global context. NNG_DECL void nng_ctx_send(nng_ctx, nng_aio *); +// nng_ctx_sendmsg is allows for sending a message synchronously using +// a context. It has the same semantics as nng_sendmsg, but operates +// on a context instead of a socket. +NNG_DECL int nng_ctx_sendmsg(nng_ctx, nng_msg *, int); + NNG_DECL int nng_ctx_get(nng_ctx, const char *, void *, size_t *); NNG_DECL int nng_ctx_get_bool(nng_ctx, const char *, bool *); NNG_DECL int nng_ctx_get_int(nng_ctx, const char *, int *); @@ -120,29 +120,33 @@ nng_recv(nng_socket s, void *buf, size_t *szp, int flags) int nng_recvmsg(nng_socket s, nng_msg **msgp, int flags) { - int rv; - nng_aio *ap; + int rv; + nni_sock *sock; + nni_aio aio; - if ((rv = nng_aio_alloc(&ap, NULL, NULL)) != 0) { + if ((rv = nni_sock_find(&sock, s.id)) != 0) { return (rv); } + + nni_aio_init(&aio, NULL, NULL); if (flags & NNG_FLAG_NONBLOCK) { - nng_aio_set_timeout(ap, NNG_DURATION_ZERO); + nng_aio_set_timeout(&aio, NNG_DURATION_ZERO); } else { - nng_aio_set_timeout(ap, NNG_DURATION_DEFAULT); + nng_aio_set_timeout(&aio, NNG_DURATION_DEFAULT); } + nni_sock_recv(sock, &aio); + nni_sock_rele(sock); - nng_recv_aio(s, ap); - nng_aio_wait(ap); + nni_aio_wait(&aio); - if ((rv = nng_aio_result(ap)) == 0) { - *msgp = nng_aio_get_msg(ap); + if ((rv = nni_aio_result(&aio)) == 0) { + *msgp = nng_aio_get_msg(&aio); } else if ((rv == NNG_ETIMEDOUT) && ((flags & NNG_FLAG_NONBLOCK) == NNG_FLAG_NONBLOCK)) { rv = NNG_EAGAIN; } - nng_aio_free(ap); + nni_aio_fini(&aio); return (rv); } @@ -171,24 +175,31 @@ nng_send(nng_socket s, void *buf, size_t len, int flags) int nng_sendmsg(nng_socket s, nng_msg *msg, int flags) { - int rv; - nng_aio *ap; + int rv; + nni_aio aio; + nni_sock *sock; - if ((rv = nng_aio_alloc(&ap, NULL, NULL)) != 0) { + if (msg == NULL) { + return (NNG_EINVAL); + } + if ((rv = nni_sock_find(&sock, s.id)) != 0) { return (rv); } + + nni_aio_init(&aio, NULL, NULL); if ((flags & NNG_FLAG_NONBLOCK) == NNG_FLAG_NONBLOCK) { - nng_aio_set_timeout(ap, NNG_DURATION_ZERO); + nni_aio_set_timeout(&aio, NNG_DURATION_ZERO); } else { - nng_aio_set_timeout(ap, NNG_DURATION_DEFAULT); + nni_aio_set_timeout(&aio, NNG_DURATION_DEFAULT); } - nng_aio_set_msg(ap, msg); - nng_send_aio(s, ap); - nng_aio_wait(ap); + nng_aio_set_msg(&aio, msg); + nni_sock_send(sock, &aio); + nni_sock_rele(sock); - rv = nng_aio_result(ap); - nng_aio_free(ap); + nni_aio_wait(&aio); + rv = nni_aio_result(&aio); + nni_aio_fini(&aio); // Possibly massage nonblocking attempt. Note that nonblocking is // still done asynchronously, and the calling thread loses context. @@ -242,7 +253,7 @@ int nng_ctx_open(nng_ctx *cp, nng_socket s) { nni_sock *sock; - nni_ctx * ctx; + nni_ctx *ctx; int rv; nng_ctx c; @@ -280,6 +291,40 @@ nng_ctx_id(nng_ctx c) return (((int) c.id > 0) ? (int) c.id : -1); } +int +nng_ctx_recvmsg(nng_ctx cid, nng_msg **msgp, int flags) +{ + int rv; + nni_aio aio; + nni_ctx *ctx; + + if ((rv = nni_ctx_find(&ctx, cid.id, false)) != 0) { + return (rv); + } + + nni_aio_init(&aio, NULL, NULL); + if (flags & NNG_FLAG_NONBLOCK) { + nng_aio_set_timeout(&aio, NNG_DURATION_ZERO); + } else { + nng_aio_set_timeout(&aio, NNG_DURATION_DEFAULT); + } + nni_ctx_recv(ctx, &aio); + nni_ctx_rele(ctx); + + nni_aio_wait(&aio); + + if ((rv = nni_aio_result(&aio)) == 0) { + *msgp = nng_aio_get_msg(&aio); + + } else if ((rv == NNG_ETIMEDOUT) && + ((flags & NNG_FLAG_NONBLOCK) == NNG_FLAG_NONBLOCK)) { + rv = NNG_EAGAIN; + } + nni_aio_fini(&aio); + + return (rv); +} + void nng_ctx_recv(nng_ctx cid, nng_aio *aio) { @@ -318,6 +363,45 @@ nng_ctx_send(nng_ctx cid, nng_aio *aio) nni_ctx_rele(ctx); } +int +nng_ctx_sendmsg(nng_ctx cid, nng_msg *msg, int flags) +{ + int rv; + nni_aio aio; + nni_ctx *ctx; + + if (msg == NULL) { + return (NNG_EINVAL); + } + if ((rv = nni_ctx_find(&ctx, cid.id, false)) != 0) { + return (rv); + } + + nni_aio_init(&aio, NULL, NULL); + if ((flags & NNG_FLAG_NONBLOCK) == NNG_FLAG_NONBLOCK) { + nni_aio_set_timeout(&aio, NNG_DURATION_ZERO); + } else { + nni_aio_set_timeout(&aio, NNG_DURATION_DEFAULT); + } + + nng_aio_set_msg(&aio, msg); + nni_ctx_send(ctx, &aio); + nni_ctx_rele(ctx); + + nni_aio_wait(&aio); + rv = nni_aio_result(&aio); + nni_aio_fini(&aio); + + // Possibly massage nonblocking attempt. Note that nonblocking is + // still done asynchronously, and the calling thread loses context. + if ((rv == NNG_ETIMEDOUT) && + ((flags & NNG_FLAG_NONBLOCK) == NNG_FLAG_NONBLOCK)) { + rv = NNG_EAGAIN; + } + + return (rv); +} + static int ctx_get(nng_ctx id, const char *n, void *v, size_t *szp, nni_type t) { @@ -466,7 +550,7 @@ nng_dial(nng_socket sid, const char *addr, nng_dialer *dp, int flags) { nni_dialer *d; int rv; - nni_sock * s; + nni_sock *s; if ((rv = nni_sock_find(&s, sid.id)) != 0) { return (rv); @@ -492,7 +576,7 @@ int nng_listen(nng_socket sid, const char *addr, nng_listener *lp, int flags) { int rv; - nni_sock * s; + nni_sock *s; nni_listener *l; if ((rv = nni_sock_find(&s, sid.id)) != 0) { @@ -519,7 +603,7 @@ nng_listen(nng_socket sid, const char *addr, nng_listener *lp, int flags) int nng_listener_create(nng_listener *lp, nng_socket sid, const char *addr) { - nni_sock * s; + nni_sock *s; int rv; nni_listener *l; nng_listener lid; @@ -560,7 +644,7 @@ nng_listener_id(nng_listener l) int nng_dialer_create(nng_dialer *dp, nng_socket sid, const char *addr) { - nni_sock * s; + nni_sock *s; nni_dialer *d; int rv; nng_dialer did; @@ -1247,7 +1331,7 @@ nng_socket nng_pipe_socket(nng_pipe p) { nng_socket s = NNG_SOCKET_INITIALIZER; - nni_pipe * pipe; + nni_pipe *pipe; if ((nni_init() == 0) && (nni_pipe_find(&pipe, p.id) == 0)) { s.id = nni_pipe_sock_id(pipe); @@ -1260,7 +1344,7 @@ nng_dialer nng_pipe_dialer(nng_pipe p) { nng_dialer d = NNG_DIALER_INITIALIZER; - nni_pipe * pipe; + nni_pipe *pipe; if ((nni_init() == 0) && (nni_pipe_find(&pipe, p.id) == 0)) { d.id = nni_pipe_dialer_id(pipe); nni_pipe_rele(pipe); @@ -1272,7 +1356,7 @@ nng_listener nng_pipe_listener(nng_pipe p) { nng_listener l = NNG_LISTENER_INITIALIZER; - nni_pipe * pipe; + nni_pipe *pipe; if ((nni_init() == 0) && (nni_pipe_find(&pipe, p.id) == 0)) { l.id = nni_pipe_listener_id(pipe); nni_pipe_rele(pipe); diff --git a/src/sp/protocol/survey0/survey_test.c b/src/sp/protocol/survey0/survey_test.c index 95d27adf..1e1b8635 100644 --- a/src/sp/protocol/survey0/survey_test.c +++ b/src/sp/protocol/survey0/survey_test.c @@ -1,5 +1,5 @@ // -// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // // This software is supplied under the terms of the MIT License, a @@ -15,7 +15,7 @@ test_surv_identity(void) { nng_socket s; int p; - char * n; + char *n; NUTS_PASS(nng_surveyor0_open(&s)); NUTS_PASS(nng_socket_get_int(s, NNG_OPT_PROTO, &p)); @@ -74,7 +74,7 @@ test_surv_survey_time_option(void) nng_duration d; bool b; size_t sz = sizeof(b); - const char * opt = NNG_OPT_SURVEYOR_SURVEYTIME; + const char *opt = NNG_OPT_SURVEYOR_SURVEYTIME; NUTS_PASS(nng_surveyor0_open(&surv)); @@ -93,7 +93,7 @@ void test_surv_recv_bad_state(void) { nng_socket surv; - nng_msg * msg = NULL; + nng_msg *msg = NULL; NUTS_PASS(nng_surveyor0_open(&surv)); NUTS_FAIL(nng_recvmsg(surv, &msg, 0), NNG_ESTATE); @@ -106,7 +106,7 @@ test_surv_recv_garbage(void) { nng_socket resp; nng_socket surv; - nng_msg * m; + nng_msg *m; uint32_t surv_id; NUTS_PASS(nng_respondent0_open_raw(&resp)); @@ -216,7 +216,7 @@ test_surv_cancel(void) void test_surv_cancel_abort_recv(void) { - nng_aio * aio; + nng_aio *aio; nng_duration time = SECOND * 10; // 10s (kind of never) nng_socket surv; nng_socket resp; @@ -334,7 +334,7 @@ test_surv_poll_readable(void) int fd; nng_socket surv; nng_socket resp; - nng_msg * msg; + nng_msg *msg; NUTS_PASS(nng_surveyor0_open(&surv)); NUTS_PASS(nng_respondent0_open(&resp)); @@ -392,8 +392,8 @@ test_surv_ctx_recv_nonblock(void) nng_socket surv; nng_socket resp; nng_ctx ctx; - nng_aio * aio; - nng_msg * msg; + nng_aio *aio; + nng_msg *msg; NUTS_PASS(nng_surveyor0_open(&surv)); NUTS_PASS(nng_respondent0_open(&resp)); @@ -418,12 +418,38 @@ test_surv_ctx_recv_nonblock(void) } static void +test_surv_ctx_send_recv_msg(void) +{ + nng_socket surv; + nng_socket resp; + nng_ctx ctx1; + nng_ctx ctx2; + nng_msg *msg; + + NUTS_PASS(nng_surveyor0_open(&surv)); + NUTS_PASS(nng_respondent0_open(&resp)); + NUTS_PASS(nng_ctx_open(&ctx1, surv)); + NUTS_PASS(nng_ctx_open(&ctx2, resp)); + NUTS_PASS(nng_msg_alloc(&msg, 0)); + + NUTS_MARRY(surv, resp); + + NUTS_PASS(nng_ctx_sendmsg(ctx1, msg, 0)); + NUTS_PASS(nng_ctx_recvmsg(ctx2, &msg, 0)); + nng_msg_free(msg); + NUTS_PASS(nng_ctx_close(ctx1)); + NUTS_PASS(nng_ctx_close(ctx2)); + NUTS_CLOSE(surv); + NUTS_CLOSE(resp); +} + +static void test_surv_ctx_send_nonblock(void) { nng_socket surv; nng_ctx ctx; - nng_aio * aio; - nng_msg * msg; + nng_aio *aio; + nng_msg *msg; NUTS_PASS(nng_surveyor0_open(&surv)); NUTS_PASS(nng_ctx_open(&ctx, surv)); @@ -490,8 +516,8 @@ test_surv_ctx_recv_close_socket(void) nng_socket surv; nng_socket resp; nng_ctx ctx; - nng_aio * aio; - nng_msg * m; + nng_aio *aio; + nng_msg *m; NUTS_PASS(nng_surveyor0_open(&surv)); NUTS_PASS(nng_respondent0_open(&resp)); @@ -518,8 +544,8 @@ test_surv_context_multi(void) nng_socket surv; nng_socket resp; nng_ctx c[5]; - nng_aio * aio; - nng_msg * m; + nng_aio *aio; + nng_msg *m; int cnt = sizeof(c) / sizeof(c[0]); NUTS_PASS(nng_surveyor0_open(&surv)); @@ -575,9 +601,9 @@ static void test_surv_validate_peer(void) { nng_socket s1, s2; - nng_stat * stats; - nng_stat * reject; - char * addr; + nng_stat *stats; + nng_stat *reject; + char *addr; NUTS_ADDR(addr, "inproc"); NUTS_PASS(nng_surveyor0_open(&s1)); @@ -618,6 +644,7 @@ TEST_LIST = { test_surv_ctx_recv_close_socket }, { "survey context recv nonblock", test_surv_ctx_recv_nonblock }, { "survey context send nonblock", test_surv_ctx_send_nonblock }, + { "survey context send recv msg", test_surv_ctx_send_recv_msg }, { "survey timeout", test_surv_survey_timeout }, { "survey send best effort", test_surv_send_best_effort }, { "survey context multi", test_surv_context_multi }, |
