From 465e2660e34f7c5e4b00f63f8c7d6900e5f76a2e Mon Sep 17 00:00:00 2001 From: Andy Green Date: Sun, 8 May 2016 17:10:51 +0800 Subject: [PATCH] context only destroy protocols if init got sent If for some reason we exit before the protocol init action (which is delayed for libuv) we should not send the protocol destroy messages Signed-off-by: Andy Green --- lib/context.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/context.c b/lib/context.c index 8c0a69b..83be24b 100644 --- a/lib/context.c +++ b/lib/context.c @@ -703,7 +703,7 @@ lws_context_destroy(struct lws_context *context) { const struct lws_protocols *protocol = NULL; struct lws_context_per_thread *pt; - struct lws_vhost *vh, *vh1; + struct lws_vhost *vh = NULL, *vh1; struct lws wsi; int n, m; @@ -754,7 +754,8 @@ lws_context_destroy(struct lws_context *context) * * We can't free things until after the event loop shuts down. */ - vh = context->vhost_list; + if (context->protocol_init_done) + vh = context->vhost_list; while (vh) { wsi.vhost = vh; protocol = vh->protocols; -- 2.7.4