summaryrefslogtreecommitdiff
path: root/src/platform/windows/win_thread.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2019-12-30 14:18:35 -0800
committerGarrett D'Amore <garrett@damore.org>2019-12-31 11:29:47 -0800
commit092a24eea6ae494be8f7a5fe543e634cca01022e (patch)
tree8579884b571773c65efde3edecf3b2289697798b /src/platform/windows/win_thread.c
parentb4d3ff2d460607ba8e1b351233cb6cbe9f031264 (diff)
downloadnng-092a24eea6ae494be8f7a5fe543e634cca01022e.tar.gz
nng-092a24eea6ae494be8f7a5fe543e634cca01022e.tar.bz2
nng-092a24eea6ae494be8f7a5fe543e634cca01022e.zip
fixes #1075 WebSocket heap use after free
This also introduces a new atomic boolean type, so we can use that to trigger whether we've added the HTTP handler or not.
Diffstat (limited to 'src/platform/windows/win_thread.c')
-rw-r--r--src/platform/windows/win_thread.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/platform/windows/win_thread.c b/src/platform/windows/win_thread.c
index 076da9e4..763dcf7f 100644
--- a/src/platform/windows/win_thread.c
+++ b/src/platform/windows/win_thread.c
@@ -132,6 +132,30 @@ nni_atomic_flag_reset(nni_atomic_flag *f)
}
void
+nni_atomic_set_bool(nni_atomic_bool *v, bool b)
+{
+ InterlockedExchange(&v->v, (LONG) b);
+}
+
+bool
+nni_atomic_get_bool(nni_atomic_bool *v)
+{
+ return ((bool) InterlockedAdd(&v->v, 0));
+}
+
+bool
+nni_atomic_swap_bool(nni_atomic_bool *v, bool b)
+{
+ return ((bool) InterlockedExchange(&v->v, (LONG) b));
+}
+
+void
+nni_atomic_init_bool(nni_atomic_bool *v)
+{
+ InterlockedExchange(&v->v, 0);
+}
+
+void
nni_atomic_add64(nni_atomic_u64 *v, uint64_t bump)
{
InterlockedAddNoFence64(&v->v, (LONGLONG) bump);