diff --git a/lib/core-net/vhost.c b/lib/core-net/vhost.c index ed41b8770..cc6338f4b 100644 --- a/lib/core-net/vhost.c +++ b/lib/core-net/vhost.c @@ -1146,8 +1146,10 @@ __lws_vhost_destroy2(struct lws_vhost *vh) /* add ourselves to the pending destruction list */ - vh->vhost_next = vh->context->vhost_pending_destruction_list; - vh->context->vhost_pending_destruction_list = vh; + if (vh->context->vhost_pending_destruction_list != vh) { + vh->vhost_next = vh->context->vhost_pending_destruction_list; + vh->context->vhost_pending_destruction_list = vh; + } lwsl_info("%s: %p\n", __func__, vh);