aboutsummaryrefslogtreecommitdiff
path: root/src/transport/tcp
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-07-02 22:36:08 -0700
committerGarrett D'Amore <garrett@damore.org>2018-07-03 19:00:19 -0700
commitd1a9c84a6b375cb25a8b7475957130e364b41753 (patch)
tree5444721d96a84d92e3ed258b4d51f80adf6b200c /src/transport/tcp
parenta772bcc6ebe198f939889abbda18eded2a326941 (diff)
downloadnng-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/tcp')
-rw-r--r--src/transport/tcp/tcp.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/transport/tcp/tcp.c b/src/transport/tcp/tcp.c
index 1a183ecd..e8aa04d0 100644
--- a/src/transport/tcp/tcp.c
+++ b/src/transport/tcp/tcp.c
@@ -882,7 +882,11 @@ static int
tcp_ep_get_nodelay(void *arg, void *v, size_t *szp, nni_opt_type t)
{
tcp_ep *ep = arg;
- return (nni_copyout_bool(ep->nodelay, v, szp, t));
+ int rv;
+ nni_mtx_lock(&ep->mtx);
+ rv = nni_copyout_bool(ep->nodelay, v, szp, t);
+ nni_mtx_unlock(&ep->mtx);
+ return (rv);
}
static int
@@ -903,7 +907,11 @@ static int
tcp_ep_get_keepalive(void *arg, void *v, size_t *szp, nni_opt_type t)
{
tcp_ep *ep = arg;
- return (nni_copyout_bool(ep->keepalive, v, szp, t));
+ int rv;
+ nni_mtx_lock(&ep->mtx);
+ rv = nni_copyout_bool(ep->keepalive, v, szp, t);
+ nni_mtx_unlock(&ep->mtx);
+ return (rv);
}
static int
@@ -931,7 +939,11 @@ static int
tcp_ep_get_recvmaxsz(void *arg, void *v, size_t *szp, nni_opt_type t)
{
tcp_ep *ep = arg;
- return (nni_copyout_size(ep->rcvmax, v, szp, t));
+ int rv;
+ nni_mtx_lock(&ep->mtx);
+ rv = nni_copyout_size(ep->rcvmax, v, szp, t);
+ nni_mtx_unlock(&ep->mtx);
+ return (rv);
}
static nni_tran_option tcp_pipe_options[] = {