valgrind: avoid complaints from plugin loading

This commit is contained in:
Andy Green 2017-07-15 17:57:14 +08:00
parent 5106e9141f
commit d5f960f14b
2 changed files with 8 additions and 7 deletions

View file

@ -572,7 +572,6 @@ lws_plat_plugins_init(struct lws_context *context, const char * const *d)
uv_dirent_t dent; uv_dirent_t dent;
uv_fs_t req; uv_fs_t req;
char path[256]; char path[256];
uv_loop_t loop;
uv_lib_t lib; uv_lib_t lib;
int pofs = 0; int pofs = 0;
@ -583,14 +582,14 @@ lws_plat_plugins_init(struct lws_context *context, const char * const *d)
lib.errmsg = NULL; lib.errmsg = NULL;
lib.handle = NULL; lib.handle = NULL;
uv_loop_init(&loop); uv_loop_init(&context->pu_loop);
lwsl_notice(" Plugins:\n"); lwsl_notice(" Plugins:\n");
while (d && *d) { while (d && *d) {
lwsl_notice(" Scanning %s\n", *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) { if (m < 1) {
lwsl_err("Scandir on %s failed\n", *d); lwsl_err("Scandir on %s failed\n", *d);
return 1; return 1;
@ -624,6 +623,7 @@ lws_plat_plugins_init(struct lws_context *context, const char * const *d)
uv_dlerror(&lib); uv_dlerror(&lib);
lwsl_err("Failed to get %s on %s: %s", path, lwsl_err("Failed to get %s on %s: %s", path,
dent.name, lib.errmsg); dent.name, lib.errmsg);
uv_dlclose(&lib);
goto bail; goto bail;
} }
initfunc = (lws_plugin_init_func)v; 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)); plugin = lws_malloc(sizeof(*plugin));
if (!plugin) { if (!plugin) {
uv_dlclose(&lib);
lwsl_err("OOM\n"); lwsl_err("OOM\n");
goto bail; goto bail;
} }
@ -658,11 +659,7 @@ bail:
d++; d++;
} }
uv_run(&loop, UV_RUN_NOWAIT);
uv_loop_close(&loop);
return ret; return ret;
} }
LWS_VISIBLE int LWS_VISIBLE int
@ -715,6 +712,9 @@ lws_plat_plugins_destroy(struct lws_context *context)
context->plugin_list = NULL; context->plugin_list = NULL;
while (uv_loop_close(&context->pu_loop))
;
return 0; return 0;
} }

View file

@ -958,6 +958,7 @@ struct lws_context {
#endif #endif
#if defined(LWS_USE_LIBUV) #if defined(LWS_USE_LIBUV)
uv_signal_cb lws_uv_sigint_cb; uv_signal_cb lws_uv_sigint_cb;
uv_loop_t pu_loop;
#endif #endif
#if defined(LWS_USE_LIBEVENT) #if defined(LWS_USE_LIBEVENT)
lws_event_signal_cb_t * lws_event_sigint_cb; lws_event_signal_cb_t * lws_event_sigint_cb;