1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-23 00:00:06 +01:00

lws_remove_child_from_any_parent: clear parent pointer and fix failure message

This commit is contained in:
Andy Green 2017-03-30 08:31:36 +08:00
parent 73e12e7b93
commit db64bfcefa

View file

@ -146,23 +146,27 @@ static void
lws_remove_child_from_any_parent(struct lws *wsi) lws_remove_child_from_any_parent(struct lws *wsi)
{ {
struct lws **pwsi; struct lws **pwsi;
int seen = 0;
if (wsi->parent) { if (!wsi->parent)
/* detach ourselves from parent's child list */ return;
pwsi = &wsi->parent->child_list;
while (*pwsi) { /* detach ourselves from parent's child list */
if (*pwsi == wsi) { pwsi = &wsi->parent->child_list;
//lwsl_notice("%s: detach %p from parent %p\n", while (*pwsi) {
// __func__, wsi, wsi->parent); if (*pwsi == wsi) {
*pwsi = wsi->sibling_list; lwsl_info("%s: detach %p from parent %p\n",
break; __func__, wsi, wsi->parent);
} *pwsi = wsi->sibling_list;
pwsi = &(*pwsi)->sibling_list; seen = 1;
break;
} }
if (*pwsi) pwsi = &(*pwsi)->sibling_list;
lwsl_err("%s: failed to detach from parent\n",
__func__);
} }
if (!seen)
lwsl_err("%s: failed to detach from parent\n", __func__);
wsi->parent = NULL;
} }
int int