diff --git a/CMakeLists.txt b/CMakeLists.txt index 6367ddf4b..00ed2bd81 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1194,6 +1194,7 @@ if (WIN32) lib/plat/windows/windows-init.c lib/plat/windows/windows-misc.c lib/plat/windows/windows-pipe.c + lib/plat/windows/windows-plugins.c lib/plat/windows/windows-service.c lib/plat/windows/windows-sockets.c ) diff --git a/include/libwebsockets/lws-protocols-plugins.h b/include/libwebsockets/lws-protocols-plugins.h index b6cc44e27..d37041de6 100644 --- a/include/libwebsockets/lws-protocols-plugins.h +++ b/include/libwebsockets/lws-protocols-plugins.h @@ -217,9 +217,8 @@ struct lws_plugin { struct lws_plugin *list; /**< linked list */ #if (UV_VERSION_MAJOR > 0) uv_lib_t lib; /**< shared library pointer */ -#else - void *l; /**< so we can compile on ancient libuv */ #endif + void *l; /**< so we can compile on ancient libuv */ char name[64]; /**< name of the plugin */ struct lws_plugin_capability caps; /**< plugin capabilities */ }; diff --git a/lib/event-libs/libuv/libuv.c b/lib/event-libs/libuv/libuv.c index 88c3d3f2e..22915b2db 100644 --- a/lib/event-libs/libuv/libuv.c +++ b/lib/event-libs/libuv/libuv.c @@ -323,8 +323,8 @@ lws_libuv_check_watcher_active(struct lws *wsi) #if defined(LWS_WITH_PLUGINS) && (UV_VERSION_MAJOR > 0) -LWS_VISIBLE int -lws_plat_plugins_init(struct lws_context *context, const char * const *d) +int +lws_uv_plugins_init(struct lws_context *context, const char * const *d) { struct lws_plugin_capability lcaps; struct lws_plugin *plugin; @@ -425,8 +425,8 @@ bail: return ret; } -LWS_VISIBLE int -lws_plat_plugins_destroy(struct lws_context *context) +int +lws_uv_plugins_destroy(struct lws_context *context) { struct lws_plugin *plugin = context->plugin_list, *p; lws_plugin_destroy_func func; @@ -435,8 +435,6 @@ lws_plat_plugins_destroy(struct lws_context *context) void *v; int m; -// return 0; - #if defined(__MINGW32__) || !defined(WIN32) pofs = 3; #endif diff --git a/lib/event-libs/libuv/private.h b/lib/event-libs/libuv/private.h index 7e19c0e8b..0c17e4b43 100644 --- a/lib/event-libs/libuv/private.h +++ b/lib/event-libs/libuv/private.h @@ -67,5 +67,11 @@ struct lws_signal_watcher_libuv { extern struct lws_event_loop_ops event_loop_ops_uv; -LWS_VISIBLE uv_loop_t * +uv_loop_t * lws_uv_getloop(struct lws_context *context, int tsi); + +int +lws_uv_plugins_init(struct lws_context *context, const char * const *d); + +int +lws_uv_plugins_destroy(struct lws_context *context); diff --git a/lib/plat/unix/unix-init.c b/lib/plat/unix/unix-init.c index 135058c90..48c554735 100644 --- a/lib/plat/unix/unix-init.c +++ b/lib/plat/unix/unix-init.c @@ -57,8 +57,8 @@ lws_plat_init(struct lws_context *context, return 1; } -#ifdef LWS_WITH_PLUGINS - if (info->plugin_dirs && (context->options & LWS_SERVER_OPTION_LIBUV)) +#if defined(LWS_WITH_PLUGINS) + if (info->plugin_dirs) lws_plat_plugins_init(context, info->plugin_dirs); #endif diff --git a/lib/plat/unix/unix-plugins.c b/lib/plat/unix/unix-plugins.c index 5851c2994..a56046a20 100644 --- a/lib/plat/unix/unix-plugins.c +++ b/lib/plat/unix/unix-plugins.c @@ -30,13 +30,6 @@ #endif #include -/* - * this is a dummy implementation to keep travis happy. The real, working - * implementation can be found in event-libs/libuv/libuv.c - */ - -#if UV_VERSION_MAJOR <= 0 - static int filter(const struct dirent *ent) { if (!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, "..")) @@ -56,6 +49,11 @@ lws_plat_plugins_init(struct lws_context * context, const char * const *d) char path[256]; void *l; +#if defined(LWS_WITH_PLUGINS) && (UV_VERSION_MAJOR > 0) + if (lws_check_opt(context->options, LWS_SERVER_OPTION_LIBUV)) + return lws_uv_plugins_init(context, d); +#endif + lwsl_notice(" Plugins:\n"); while (d && *d) { @@ -125,6 +123,8 @@ lws_plat_plugins_init(struct lws_context * context, const char * const *d) d++; } + return 0; + bail: free(namelist); @@ -139,6 +139,11 @@ lws_plat_plugins_destroy(struct lws_context * context) char path[256]; int m; +#if defined(LWS_WITH_PLUGINS) && (UV_VERSION_MAJOR > 0) + if (lws_check_opt(context->options, LWS_SERVER_OPTION_LIBUV)) + return lws_uv_plugins_destroy(context); +#endif + if (!plugin) return 0; @@ -170,4 +175,3 @@ next: return 0; } -#endif diff --git a/lib/plat/windows/windows-plugins.c b/lib/plat/windows/windows-plugins.c new file mode 100644 index 000000000..7f83524f5 --- /dev/null +++ b/lib/plat/windows/windows-plugins.c @@ -0,0 +1,47 @@ +/* + * libwebsockets - small server side websockets and web server implementation + * + * Copyright (C) 2010 - 2019 Andy Green + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation: + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS +#define _WINSOCK_DEPRECATED_NO_WARNINGS +#endif +#include "core/private.h" + +int +lws_plat_plugins_init(struct lws_context * context, const char * const *d) +{ +#if defined(LWS_WITH_PLUGINS) && (UV_VERSION_MAJOR > 0) + if (lws_check_opt(context->options, LWS_SERVER_OPTION_LIBUV)) + return lws_uv_plugins_init(context, d); +#endif + + return 0; +} + +int +lws_plat_plugins_destroy(struct lws_context * context) +{ +#if defined(LWS_WITH_PLUGINS) && (UV_VERSION_MAJOR > 0) + if (lws_check_opt(context->options, LWS_SERVER_OPTION_LIBUV)) + return lws_uv_plugins_destroy(context); +#endif + + return 0; +}