]> granicus.if.org Git - ejabberd/commitdiff
Invalidate proper cache when using mam for offline in pop_messages
authorPaweł Chmielowski <pchmielowski@process-one.net>
Mon, 1 Jul 2019 12:30:21 +0000 (14:30 +0200)
committerPaweł Chmielowski <pchmielowski@process-one.net>
Mon, 1 Jul 2019 12:30:39 +0000 (14:30 +0200)
src/mod_offline.erl

index 3b41ac97d6dc00de95da0393e4e11a6b6ea34fd3..d442bd5cbf30591396b2d147a4d4741999f61103 100644 (file)
@@ -84,7 +84,6 @@
 %% default value for the maximum number of user messages
 -define(MAX_USER_MESSAGES, infinity).
 
--define(EMPTY_SPOOL_CACHE, offline_empty_cache).
 -define(SPOOL_COUNTER_CACHE, offline_msg_counter_cache).
 
 -type c2s_state() :: ejabberd_c2s:state().
@@ -178,12 +177,6 @@ init_cache(Mod, Host, Opts) ->
     CacheOpts = [{max_size, mod_offline_opt:cache_size(Opts)},
                 {life_time, mod_offline_opt:cache_life_time(Opts)},
                 {cache_missed, false}],
-    case mod_offline_opt:use_mam_for_storage(Opts) of
-        true ->
-            ets_cache:new(?EMPTY_SPOOL_CACHE, CacheOpts);
-        false ->
-            ets_cache:delete(?EMPTY_SPOOL_CACHE)
-    end,
     case use_cache(Mod, Host) of
        true ->
            ets_cache:new(?SPOOL_COUNTER_CACHE, CacheOpts);
@@ -626,8 +619,7 @@ route_offline_messages(#{jid := #jid{luser = LUser, lserver = LServer}} = State)
               {ok, OffMsgs} ->
                   case use_mam_for_user(LUser, LServer) of
                       true ->
-                          ets_cache:delete(?EMPTY_SPOOL_CACHE, {LUser, LServer},
-                                           ejabberd_cluster:get_nodes()),
+                          flush_cache(Mod, LUser, LServer),
                           lists:map(
                               fun({_, #message{from = From, to = To} = Msg}) ->
                                   #offline_msg{from = From, to = To,