&wsi->w_read.uv_watcher, wsi->desc.sockfd);
if (n) {
lwsl_err("uv_poll_init failed %d, sockfd=%p\n",
- n, (void *)(long)wsi->desc.sockfd);
+ n, (void *)(lws_intptr_t)wsi->desc.sockfd);
return -1;
}
static void lws_uv_walk_cb(uv_handle_t *handle, void *arg)
{
- uv_close(handle, lws_uv_close_cb);
+ if (!uv_is_closing(handle))
+ uv_close(handle, lws_uv_close_cb);
}
void
wsi->w_read.context = context;
if (wsi->mode == LWSCM_RAW_FILEDESC)
uv_poll_init(pt->io_loop_uv, &wsi->w_read.uv_watcher,
- desc.filefd);
+ (int)desc.filefd);
else
uv_poll_init_socket(pt->io_loop_uv, &wsi->w_read.uv_watcher,
desc.sockfd);
struct lws_context *context = lws_get_context(wsi);
/* required to defer actual deletion until libuv has processed it */
-
uv_close((uv_handle_t*)&wsi->w_read.uv_watcher, lws_libuv_closewsi);
if (context->requested_kill && context->count_wsi_allocated == 0)
lws_libuv_kill(context);
}
+static void
+lws_libuv_closewsi_m(uv_handle_t* handle)
+{
+ lws_sockfd_type sockfd = (lws_sockfd_type)(lws_intptr_t)handle->data;
+
+ compatible_close(sockfd);
+}
+
+void
+lws_libuv_closehandle_manually(struct lws *wsi)
+{
+ uv_handle_t *h = (void *)&wsi->w_read.uv_watcher;
+
+ h->data = (void *)(lws_intptr_t)wsi->desc.sockfd;
+ /* required to defer actual deletion until libuv has processed it */
+ uv_close((uv_handle_t*)&wsi->w_read.uv_watcher, lws_libuv_closewsi_m);
+}
+
+int
+lws_libuv_check_watcher_active(struct lws *wsi)
+{
+ uv_handle_t *h = (void *)&wsi->w_read.uv_watcher;
+
+ return uv_is_active(h);
+}
+
+
#if defined(LWS_WITH_PLUGINS) && (UV_VERSION_MAJOR > 0)
LWS_VISIBLE int
char path[256];
uv_loop_t loop;
uv_lib_t lib;
+ int pofs = 0;
+
+#if defined(__MINGW32__) || !defined(WIN32)
+ pofs = 3;
+#endif
lib.errmsg = NULL;
lib.handle = NULL;
lwsl_err("Error loading DSO: %s\n", lib.errmsg);
goto bail;
}
+
/* we could open it, can we get his init function? */
-#if !defined(WIN32)
+
+#if !defined(WIN32) && !defined(__MINGW32__)
m = lws_snprintf(path, sizeof(path) - 1, "init_%s",
- dent.name + 3 /* snip lib... */);
+ dent.name + pofs /* snip lib... */);
path[m - 3] = '\0'; /* snip the .so */
#else
m = lws_snprintf(path, sizeof(path) - 1, "init_%s",
- dent.name);
+ dent.name + pofs);
path[m - 4] = '\0'; /* snip the .dll */
#endif
if (uv_dlsym(&lib, path, &v)) {
uv_dlerror(&lib);
- lwsl_err("Failed to get init on %s: %s",
+ lwsl_err("Failed to get %s on %s: %s", path,
dent.name, lib.errmsg);
goto bail;
}
char path[256];
void *v;
int m;
+ int pofs = 0;
+
+#if defined(__MINGW32__) || !defined(WIN32)
+ pofs = 3;
+#endif
if (!plugin)
return 0;
while (plugin) {
p = plugin;
-#if !defined(WIN32)
- m = lws_snprintf(path, sizeof(path) - 1, "destroy_%s", plugin->name + 3);
+
+#if !defined(WIN32) && !defined(__MINGW32__)
+ m = lws_snprintf(path, sizeof(path) - 1, "destroy_%s", plugin->name + pofs);
path[m - 3] = '\0';
#else
- m = lws_snprintf(path, sizeof(path) - 1, "destroy_%s", plugin->name);
+ m = lws_snprintf(path, sizeof(path) - 1, "destroy_%s", plugin->name + pofs);
path[m - 4] = '\0';
#endif
if (uv_dlsym(&plugin->lib, path, &v)) {
uv_dlerror(&plugin->lib);
- lwsl_err("Failed to get init on %s: %s",
+ lwsl_err("Failed to get %s on %s: %s", path,
plugin->name, plugin->lib.errmsg);
} else {
func = (lws_plugin_destroy_func)v;