aboutsummaryrefslogtreecommitdiff
path: root/src/transport/ws
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/ws
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/ws')
-rw-r--r--src/transport/ws/websocket.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/transport/ws/websocket.c b/src/transport/ws/websocket.c
index 2fa0fd67..b3aef756 100644
--- a/src/transport/ws/websocket.c
+++ b/src/transport/ws/websocket.c
@@ -416,7 +416,11 @@ static int
ws_dialer_get_recvmaxsz(void *arg, void *v, size_t *szp, nni_opt_type t)
{
ws_dialer *d = arg;
- return (nni_copyout_size(d->rcvmax, v, szp, t));
+ int rv;
+ nni_mtx_lock(&d->mtx);
+ rv = nni_copyout_size(d->rcvmax, v, szp, t);
+ nni_mtx_unlock(&d->mtx);
+ return (rv);
}
static int
@@ -439,7 +443,11 @@ static int
ws_listener_get_recvmaxsz(void *arg, void *v, size_t *szp, nni_opt_type t)
{
ws_listener *l = arg;
- return (nni_copyout_size(l->rcvmax, v, szp, t));
+ int rv;
+ nni_mtx_lock(&l->mtx);
+ rv = nni_copyout_size(l->rcvmax, v, szp, t);
+ nni_mtx_unlock(&l->mtx);
+ return (rv);
}
static int
@@ -538,7 +546,9 @@ ws_dialer_set_reqhdrs(void *arg, const void *v, size_t sz, nni_opt_type t)
}
if ((rv = ws_check_string(v, sz, t)) == 0) {
+ nni_mtx_lock(&d->mtx);
rv = ws_set_headers(&d->headers, v);
+ nni_mtx_unlock(&d->mtx);
}
return (rv);
}
@@ -553,7 +563,9 @@ ws_listener_set_reshdrs(void *arg, const void *v, size_t sz, nni_opt_type t)
return (NNG_EBUSY);
}
if ((rv = ws_check_string(v, sz, t)) == 0) {
+ nni_mtx_lock(&l->mtx);
rv = ws_set_headers(&l->headers, v);
+ nni_mtx_unlock(&l->mtx);
}
return (rv);
}