From 2083674aa015b4b10544f383c6894da37086f862 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Fri, 9 Sep 2016 22:15:43 +0800 Subject: [PATCH] lws_status protect against pss list changing --- plugins/protocol_lws_status.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/plugins/protocol_lws_status.c b/plugins/protocol_lws_status.c index 3bb9864b..67b53980 100644 --- a/plugins/protocol_lws_status.c +++ b/plugins/protocol_lws_status.c @@ -148,6 +148,23 @@ callback_lws_status(struct lws *wsi, enum lws_callback_reasons reason, if (pss->subsequent) *p++ = ','; pss->subsequent = 1; + + m = 0; + pss2 = vhd->live_pss_list; + while (pss2) { + if (pss2 == pss->walk_next) { + m = 1; + break; + } + pss2 = pss2->next; + } + if (!m) { + /* our next guy went away */ + pss->walk = WALK_FINAL; + pss->changed_partway = 1; + break; + } + lws_get_peer_simple(pss->walk_next->wsi, ip, sizeof(ip)); p += snprintf(p, end - p, "{\"peer\":\"%s\",\"time\":\"%ld\","