25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

mod_pubsub: Fix last item cache for multiple hosts

Don't let the last item cache intermix PubSub items of different virtual
domains.
This commit is contained in:
Holger Weiss 2017-01-21 00:14:56 +01:00
parent 56ef607904
commit 14e771d871
2 changed files with 6 additions and 6 deletions

View File

@ -166,7 +166,7 @@
-record(pubsub_last_item,
{
nodeid ,% :: mod_pubsub:nodeIdx(),
nodeid ,% :: {binary(), mod_pubsub:nodeIdx()},
itemid ,% :: mod_pubsub:itemId(),
creation ,% :: {erlang:timestamp(), jlib:ljid()},
payload % :: mod_pubsub:payload()

View File

@ -177,7 +177,7 @@
-type(pubsubLastItem() ::
#pubsub_last_item{
nodeid :: mod_pubsub:nodeIdx(),
nodeid :: {binary(), mod_pubsub:nodeIdx()},
itemid :: mod_pubsub:itemId(),
creation :: {erlang:timestamp(), ljid()},
payload :: mod_pubsub:payload()
@ -3426,7 +3426,7 @@ set_cached_item({_, ServerHost, _}, Nidx, ItemId, Publisher, Payload) ->
set_cached_item(ServerHost, Nidx, ItemId, Publisher, Payload);
set_cached_item(Host, Nidx, ItemId, Publisher, Payload) ->
case is_last_item_cache_enabled(Host) of
true -> mnesia:dirty_write({pubsub_last_item, Nidx, ItemId,
true -> mnesia:dirty_write({pubsub_last_item, {Host, Nidx}, ItemId,
{p1_time_compat:timestamp(), jid:tolower(jid:remove_resource(Publisher))},
Payload});
_ -> ok
@ -3437,7 +3437,7 @@ unset_cached_item({_, ServerHost, _}, Nidx) ->
unset_cached_item(ServerHost, Nidx);
unset_cached_item(Host, Nidx) ->
case is_last_item_cache_enabled(Host) of
true -> mnesia:dirty_delete({pubsub_last_item, Nidx});
true -> mnesia:dirty_delete({pubsub_last_item, {Host, Nidx}});
_ -> ok
end.
@ -3447,8 +3447,8 @@ get_cached_item({_, ServerHost, _}, Nidx) ->
get_cached_item(Host, Nidx) ->
case is_last_item_cache_enabled(Host) of
true ->
case mnesia:dirty_read({pubsub_last_item, Nidx}) of
[#pubsub_last_item{itemid = ItemId, creation = Creation, payload = Payload}] ->
case mnesia:dirty_read({pubsub_last_item, {Host, Nidx}}) of
[#pubsub_last_item{itemid = {Host, ItemId}, creation = Creation, payload = Payload}] ->
% [{pubsub_last_item, Nidx, ItemId, Creation,
% Payload}] ->
#pubsub_item{itemid = {ItemId, Nidx},