From d5f960f14b81507fa052e3ea90b6b7d6de060d95 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Sat, 15 Jul 2017 17:57:14 +0800 Subject: [PATCH] valgrind: avoid complaints from plugin loading --- lib/libuv.c | 14 +++++++------- lib/private-libwebsockets.h | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/libuv.c b/lib/libuv.c index 5d58e26..fbb8c8d 100644 --- a/lib/libuv.c +++ b/lib/libuv.c @@ -572,7 +572,6 @@ lws_plat_plugins_init(struct lws_context *context, const char * const *d) uv_dirent_t dent; uv_fs_t req; char path[256]; - uv_loop_t loop; uv_lib_t lib; int pofs = 0; @@ -583,14 +582,14 @@ lws_plat_plugins_init(struct lws_context *context, const char * const *d) lib.errmsg = NULL; lib.handle = NULL; - uv_loop_init(&loop); + uv_loop_init(&context->pu_loop); lwsl_notice(" Plugins:\n"); while (d && *d) { lwsl_notice(" Scanning %s\n", *d); - m =uv_fs_scandir(&loop, &req, *d, 0, NULL); + m =uv_fs_scandir(&context->pu_loop, &req, *d, 0, NULL); if (m < 1) { lwsl_err("Scandir on %s failed\n", *d); return 1; @@ -624,6 +623,7 @@ lws_plat_plugins_init(struct lws_context *context, const char * const *d) uv_dlerror(&lib); lwsl_err("Failed to get %s on %s: %s", path, dent.name, lib.errmsg); + uv_dlclose(&lib); goto bail; } initfunc = (lws_plugin_init_func)v; @@ -636,6 +636,7 @@ lws_plat_plugins_init(struct lws_context *context, const char * const *d) plugin = lws_malloc(sizeof(*plugin)); if (!plugin) { + uv_dlclose(&lib); lwsl_err("OOM\n"); goto bail; } @@ -658,11 +659,7 @@ bail: d++; } - uv_run(&loop, UV_RUN_NOWAIT); - uv_loop_close(&loop); - return ret; - } LWS_VISIBLE int @@ -715,6 +712,9 @@ lws_plat_plugins_destroy(struct lws_context *context) context->plugin_list = NULL; + while (uv_loop_close(&context->pu_loop)) + ; + return 0; } diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h index f8471a0..1968722 100644 --- a/lib/private-libwebsockets.h +++ b/lib/private-libwebsockets.h @@ -958,6 +958,7 @@ struct lws_context { #endif #if defined(LWS_USE_LIBUV) uv_signal_cb lws_uv_sigint_cb; + uv_loop_t pu_loop; #endif #if defined(LWS_USE_LIBEVENT) lws_event_signal_cb_t * lws_event_sigint_cb; -- 2.7.4