diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e890aabf..a10489353 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -327,7 +327,7 @@ set(PACKAGE "libwebsockets") set(CPACK_PACKAGE_NAME "${PACKAGE}") set(CPACK_PACKAGE_VERSION_MAJOR "4") set(CPACK_PACKAGE_VERSION_MINOR "0") -set(CPACK_PACKAGE_VERSION_PATCH "17") +set(CPACK_PACKAGE_VERSION_PATCH "18") set(CPACK_PACKAGE_RELEASE 1) set(CPACK_GENERATOR "RPM") set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") diff --git a/lib/core/context.c b/lib/core/context.c index 66201e9c4..740d9a189 100644 --- a/lib/core/context.c +++ b/lib/core/context.c @@ -944,7 +944,9 @@ lws_context_destroy3(struct lws_context *context) #if defined(LWS_WITH_NETWORK) - lwsl_debug("%s\n", __func__); + context->finalize_destroy_after_internal_loops_stopped = 1; + if (context->event_loop_ops->destroy_context2) + context->event_loop_ops->destroy_context2(context); for (n = 0; n < context->count_threads; n++) { struct lws_context_per_thread *pt = &context->pt[n]; @@ -960,9 +962,10 @@ lws_context_destroy3(struct lws_context *context) #if defined(LWS_WITH_CGI) role_ops_cgi.pt_init_destroy(context, NULL, pt, 1); #endif - +#if 0 if (context->event_loop_ops->destroy_pt) context->event_loop_ops->destroy_pt(context, n); +#endif #if defined(LWS_ROLE_H1) || defined(LWS_ROLE_H2) while (pt->http.ah_list) @@ -1111,14 +1114,11 @@ lws_context_destroy2(struct lws_context *context) lws_check_deferred_free(context, 0, 1); #endif + lws_context_unlock(context); /* } context ------ */ -#if LWS_MAX_SMP > 1 - lws_mutex_refcount_destroy(&context->mr); -#endif #if defined(LWS_WITH_NETWORK) if (context->event_loop_ops->destroy_context2) if (context->event_loop_ops->destroy_context2(context)) { - lws_context_unlock(context); /* } context ----------- */ context->finalize_destroy_after_internal_loops_stopped = 1; return; } @@ -1130,12 +1130,10 @@ lws_context_destroy2(struct lws_context *context) for (n = 0; n < context->count_threads; n++) if (context->pt[n].inside_service) { lwsl_debug("%p: bailing as inside service\n", __func__); - lws_context_unlock(context); /* } context --- */ return; } } #endif - lws_context_unlock(context); /* } context ------------------- */ lws_context_destroy3(context); } diff --git a/lib/event-libs/libevent/libevent.c b/lib/event-libs/libevent/libevent.c index 6475d1279..4f0606e3d 100644 --- a/lib/event-libs/libevent/libevent.c +++ b/lib/event-libs/libevent/libevent.c @@ -335,8 +335,10 @@ elops_destroy_pt_event(struct lws_context *context, int tsi) if (!pt->event_loop_foreign) { event_del(pt->w_sigint.event.watcher); event_free(pt->w_sigint.event.watcher); - - event_base_free(pt->event.io_loop); + event_base_loopexit(pt->event.io_loop, NULL); + // event_base_free(pt->event.io_loop); + // pt->event.io_loop = NULL; + lwsl_notice("%s: set to exit loop\n", __func__); } } @@ -437,7 +439,9 @@ elops_destroy_context2_event(struct lws_context *context) } else lwsl_debug("%s: %d: everything closed OK\n", __func__, n); #endif + lwsl_err("%s: event_base_free\n", __func__); event_base_free(pt->event.io_loop); + pt->event.io_loop = NULL; }