diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-07-02 22:36:08 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-07-03 19:00:19 -0700 |
| commit | d1a9c84a6b375cb25a8b7475957130e364b41753 (patch) | |
| tree | 5444721d96a84d92e3ed258b4d51f80adf6b200c /src/transport/ipc | |
| parent | a772bcc6ebe198f939889abbda18eded2a326941 (diff) | |
| download | nng-d1a9c84a6b375cb25a8b7475957130e364b41753.tar.gz nng-d1a9c84a6b375cb25a8b7475957130e364b41753.tar.bz2 nng-d1a9c84a6b375cb25a8b7475957130e364b41753.zip | |
fixes #572 Several locking errors found
fixes #573 atomic flags could help
This introduces a new atomic flag, and reduces some of the global
locking. The lock refactoring work is not yet complete, but this is
a positive step forward, and should help with certain things.
While here we also fixed a compile warning due to incorrect types.
Diffstat (limited to 'src/transport/ipc')
| -rw-r--r-- | src/transport/ipc/ipc.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/transport/ipc/ipc.c b/src/transport/ipc/ipc.c index b48b82d9..7d99e507 100644 --- a/src/transport/ipc/ipc.c +++ b/src/transport/ipc/ipc.c @@ -827,14 +827,22 @@ static int ipc_ep_get_recvmaxsz(void *arg, void *data, size_t *szp, nni_opt_type t) { ipc_ep *ep = arg; - return (nni_copyout_size(ep->rcvmax, data, szp, t)); + int rv; + nni_mtx_lock(&ep->mtx); + rv = nni_copyout_size(ep->rcvmax, data, szp, t); + nni_mtx_unlock(&ep->mtx); + return (rv); } static int ipc_ep_get_addr(void *arg, void *data, size_t *szp, nni_opt_type t) { ipc_ep *ep = arg; - return (nni_copyout_sockaddr(&ep->sa, data, szp, t)); + int rv; + nni_mtx_lock(&ep->mtx); + rv = nni_copyout_sockaddr(&ep->sa, data, szp, t); + nni_mtx_unlock(&ep->mtx); + return (rv); } static int @@ -868,7 +876,9 @@ ipc_ep_set_sec_desc(void *arg, const void *data, size_t sz, nni_opt_type t) int rv; if ((rv = nni_copyin_ptr(&ptr, data, sz, t)) == 0) { + nni_mtx_lock(&ep->mtx); rv = nni_plat_ipc_ep_set_security_descriptor(ep->iep, ptr); + nni_mtx_unlock(&ep->mtx); } return (rv); } |
