From b310f712828962bf3187caf3bfe064c3531c5628 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 16 Jul 2018 17:10:47 -0700 Subject: fixes #595 mutex leak and other minor errors in TCP fixes #596 POSIX IPC should move away from pipedesc/epdesc fixes #598 TLS and TCP listeners could support NNG_OPT_LOCADDR fixes #594 Windows IPC should use "new style" win_io code. fixes #597 macOS could support PEER PID This large change set cleans up the IPC support on Windows and POSIX. This has the beneficial impact of significantly reducing the complexity of the code, reducing locking, increasing concurrency (multiple dial and accepts can be outstanding now), reducing context switches (we complete thins synchronously now). While here we have added some missing option support, and fixed a few more bugs that we found in the TCP code changes from last week. --- src/transport/tls/tls.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/transport/tls/tls.c') diff --git a/src/transport/tls/tls.c b/src/transport/tls/tls.c index b1bdddb8..e6701f5f 100644 --- a/src/transport/tls/tls.c +++ b/src/transport/tls/tls.c @@ -913,9 +913,9 @@ tlstran_listener_bind(void *arg) tlstran_listener *l = arg; int rv; - l->bsa = l->sa; nni_mtx_lock(&l->ep.mtx); - rv = nni_tcp_listener_listen(l->listener, &l->bsa); + l->bsa = l->sa; + rv = nni_tcp_listener_listen(l->listener, &l->bsa); nni_mtx_unlock(&l->ep.mtx); return (rv); @@ -1121,6 +1121,18 @@ tlstran_listener_get_url(void *arg, void *v, size_t *szp, nni_opt_type t) return (nni_copyout_str(ustr, v, szp, t)); } +static int +tlstran_listener_get_locaddr(void *arg, void *buf, size_t *szp, nni_opt_type t) +{ + tlstran_listener *l = arg; + int rv; + + nni_mtx_lock(&l->ep.mtx); + rv = nni_copyout_sockaddr(&l->bsa, buf, szp, t); + nni_mtx_unlock(&l->ep.mtx); + return (rv); +} + static int tlstran_check_recvmaxsz(const void *v, size_t sz, nni_opt_type t) { @@ -1380,6 +1392,11 @@ static nni_tran_option tlstran_listener_options[] = { .o_type = NNI_TYPE_STRING, .o_get = tlstran_listener_get_url, }, + { + .o_name = NNG_OPT_LOCADDR, + .o_type = NNI_TYPE_SOCKADDR, + .o_get = tlstran_listener_get_locaddr, + }, { .o_name = NNG_OPT_TLS_CONFIG, .o_type = NNI_TYPE_POINTER, -- cgit v1.2.3-70-g09d2