mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-30 00:00:16 +01:00
event libs: context_destroy sequencing
This commit is contained in:
parent
0648a83ca2
commit
fdb9b7fdd3
3 changed files with 19 additions and 4 deletions
|
@ -937,7 +937,11 @@ lws_context_destroy3(struct lws_context *context)
|
|||
|
||||
#if defined(LWS_WITH_NETWORK)
|
||||
|
||||
lwsl_debug("%s\n", __func__);
|
||||
lwsl_err("%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];
|
||||
|
@ -953,9 +957,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)
|
||||
|
|
|
@ -357,6 +357,11 @@ elops_io_glib(struct lws *wsi, int flags)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!wsi_to_subclass(wsi)) {
|
||||
lwsl_err("%s: glib wsi source pointer is NULL\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
g_source_modify_unix_fd(wsi_to_gsource(wsi), wsi_to_subclass(wsi)->tag,
|
||||
cond);
|
||||
}
|
||||
|
|
|
@ -134,6 +134,7 @@ lws_event_cb(evutil_socket_t sock_fd, short revents, void *ctx)
|
|||
lws_service_fd_tsi(context, &eventfd, wsi->tsi);
|
||||
|
||||
if (pt->destroy_self) {
|
||||
lwsl_notice("%s: pt destroy self coming true\n", __func__);
|
||||
lws_context_destroy(pt->context);
|
||||
return;
|
||||
}
|
||||
|
@ -326,8 +327,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__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -428,7 +431,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;
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue