summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSterling Jensen <sjj@sterlingjensen.com>2016-05-12 20:22:35 -0500
committerAndy Green <andy@warmcat.com>2016-05-13 09:43:12 +0800
commite4ea29bd51d903432c6f432e8219c3a6c25ee081 (patch)
tree6d66a0e1a0e3077f59c41d58d6b24fe2303a12e2
parent6d19521b90eb100ddb17d9c8f54da08931a23cc9 (diff)
downloadlibwebsockets-e4ea29bd51d903432c6f432e8219c3a6c25ee081.tar.gz
libwebsockets-e4ea29bd51d903432c6f432e8219c3a6c25ee081.tar.bz2
libwebsockets-e4ea29bd51d903432c6f432e8219c3a6c25ee081.zip
Fix leak caused by undestroyed pthread mutex
-rw-r--r--lib/context.c1
-rw-r--r--lib/private-libwebsockets.h8
2 files changed, 9 insertions, 0 deletions
diff --git a/lib/context.c b/lib/context.c
index 68583abe..eb8169c7 100644
--- a/lib/context.c
+++ b/lib/context.c
@@ -387,6 +387,7 @@ lws_context_destroy(struct lws_context *context)
/* no protocol close */);
n--;
}
+ lws_pt_mutex_destroy(pt);
}
/*
* give all extensions a chance to clean up any per-context
diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h
index b3068a62..2a5080f2 100644
--- a/lib/private-libwebsockets.h
+++ b/lib/private-libwebsockets.h
@@ -1388,6 +1388,13 @@ lws_pt_mutex_init(struct lws_context_per_thread *pt)
{
pthread_mutex_init(&pt->lock, NULL);
}
+
+static LWS_INLINE void
+lws_pt_mutex_destroy(struct lws_context_per_thread *pt)
+{
+ pthread_mutex_destroy(&pt->lock);
+}
+
static LWS_INLINE void
lws_pt_lock(struct lws_context_per_thread *pt)
{
@@ -1401,6 +1408,7 @@ lws_pt_unlock(struct lws_context_per_thread *pt)
}
#else
#define lws_pt_mutex_init(_a) (void)(_a)
+#define lws_pt_mutex_destroy(_a) (void)(_a)
#define lws_pt_lock(_a) (void)(_a)
#define lws_pt_unlock(_a) (void)(_a)
#endif