From e236dc8141f4d00dc926fbfba7739dabf96ebcdd Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Wed, 20 Sep 2017 12:11:53 -0700 Subject: More pipe option handling, pipe API support. Url option. This fleshes most of the pipe API out, making it available to end user code. It also adds a URL option that is independent of the address options (which would be sockaddrs.) Also, we are now setting the pipe for req/rep. The other protocols need to have the same logic added to set the receive pipe on the message. (Pair is already done.) --- src/nng.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'src/nng.c') diff --git a/src/nng.c b/src/nng.c index ca686686..32004895 100644 --- a/src/nng.c +++ b/src/nng.c @@ -663,30 +663,34 @@ nng_strerror(int num) return ("Unknown error"); } -#if 0 int -nng_pipe_getopt(nng_pipe *pipe, int opt, void *val, size_t *sizep) +nng_pipe_getopt(nng_pipe id, int opt, void *val, size_t *sizep) { - int rv; + int rv; + nni_pipe *p; - rv = nni_pipe_getopt(pipe, opt, val, sizep); - if (rv == ENOTSUP) { - // Maybe its a generic socket option. - rv = nni_sock_getopt(pipe->p_sock, opt, val, sizep); + if ((rv = nni_pipe_find(&p, id)) != 0) { + return (rv); } + rv = nni_pipe_getopt(p, opt, val, sizep); + nni_pipe_rele(p); return (rv); } - int -nng_pipe_close(nng_pipe *pipe) +nng_pipe_close(nng_pipe id) { - nni_pipe_close(pipe); + int rv; + nni_pipe *p; + + if ((rv = nni_pipe_find(&p, id)) != 0) { + return (rv); + } + nni_pipe_close(p); + nni_pipe_rele(p); return (0); } -#endif - // Message handling. int nng_msg_alloc(nng_msg **msgp, size_t size) @@ -1012,6 +1016,7 @@ const char *nng_opt_recvfd = "recv-fd"; const char *nng_opt_sendfd = "send-fd"; const char *nng_opt_locaddr = "local-address"; const char *nng_opt_remaddr = "remote-address"; +const char *nng_opt_url = "url"; // Well known protocol options. const char *nng_opt_req_resendtime = "req:resend-time"; const char *nng_opt_sub_subscribe = "sub:subscribe"; @@ -1034,6 +1039,7 @@ int nng_optid_recvfd; int nng_optid_sendfd; int nng_optid_locaddr; int nng_optid_remaddr; +int nng_optid_url; int nng_optid_req_resendtime; int nng_optid_sub_subscribe; int nng_optid_sub_unsubscribe; -- cgit v1.2.3-70-g09d2