From: Christophe Romain Date: Thu, 23 Feb 2017 15:43:22 +0000 (+0100) Subject: Avoid orphan_item leak on affiliation/subscription removal (#1563) X-Git-Tag: 17.03-beta~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=720741b7255a24997f7952bbb5d2f302bbd453ed;p=ejabberd Avoid orphan_item leak on affiliation/subscription removal (#1563) --- diff --git a/src/node_flat.erl b/src/node_flat.erl index 1809915ff..907858428 100644 --- a/src/node_flat.erl +++ b/src/node_flat.erl @@ -707,7 +707,13 @@ del_state(#pubsub_state{stateid = {Key, Nidx}, items = Items}) -> [] -> ok; _ -> - Orphan = #pubsub_orphan{nodeid = Nidx, items = Items}, + Orphan = #pubsub_orphan{nodeid = Nidx, items = + case mnesia:read({pubsub_orphan, Nidx}) of + [#pubsub_orphan{items = ItemIds}] -> + lists:usort(ItemIds++Items); + _ -> + Items + end}, mnesia:write(Orphan) end, mnesia:delete({pubsub_state, {Key, Nidx}}).