Fix leak caused by undestroyed pthread mutex
authorSterling Jensen <sjj@sterlingjensen.com>
Fri, 13 May 2016 01:22:35 +0000 (20:22 -0500)
committerAndy Green <andy@warmcat.com>
Fri, 13 May 2016 01:43:12 +0000 (09:43 +0800)
lib/context.c
lib/private-libwebsockets.h

index 68583abea1ccc887b4b280af2666c92599da3e0c..eb8169c7fb8babd5d427ead9bf7fcd8e8cf9abea 100644 (file)
@@ -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
index b3068a620279afd24d5b726ab28d63efacc3810d..2a5080f22ca92d189b0f89d469fda4b48ed4110d 100644 (file)
@@ -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