From 56e52f057107a1db4ad00fd263b8ee93c0539c49 Mon Sep 17 00:00:00 2001 From: Christophe Romain Date: Thu, 20 Aug 2009 13:07:58 +0000 Subject: [PATCH] fixing pubsub_subscription issue when changed transaction to sync_dirty SVN Revision: 2508 --- src/mod_pubsub/mod_pubsub.erl | 6 ++++-- src/mod_pubsub/pubsub_subscription.erl | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/mod_pubsub/mod_pubsub.erl b/src/mod_pubsub/mod_pubsub.erl index fe0149dec..d24b0a407 100644 --- a/src/mod_pubsub/mod_pubsub.erl +++ b/src/mod_pubsub/mod_pubsub.erl @@ -2952,8 +2952,10 @@ get_node_subs(#pubsub_node{type = Type, get_options_for_subs(_Host, Node, NodeID, Subs) -> lists:foldl(fun({JID, subscribed, SubID}, Acc) -> - {result, #pubsub_subscription{options = Options}} = pubsub_subscription:get_subscription(JID, NodeID, SubID), - [{JID, Node, Options} | Acc]; + case pubsub_subscription:get_subscription(JID, NodeID, SubID) of + {result, #pubsub_subscription{options = Options}} -> [{JID, Node, Options} | Acc]; + _ -> Acc + end; (_, Acc) -> Acc end, [], Subs). diff --git a/src/mod_pubsub/pubsub_subscription.erl b/src/mod_pubsub/pubsub_subscription.erl index 5f3038d35..e41acc518 100644 --- a/src/mod_pubsub/pubsub_subscription.erl +++ b/src/mod_pubsub/pubsub_subscription.erl @@ -92,31 +92,31 @@ init() -> ok = create_table(). subscribe_node(JID, NodeID, Options) -> - case mnesia:sync_dirty(fun add_subscription/3, + case catch mnesia:sync_dirty(fun add_subscription/3, [JID, NodeID, Options]) of - {atomic, Result} -> {result, Result}; - {aborted, Error} -> Error + {'EXIT', {aborted, Error}} -> Error; + Result -> {result, Result} end. unsubscribe_node(JID, NodeID, SubID) -> - case mnesia:sync_dirty(fun delete_subscription/3, + case catch mnesia:sync_dirty(fun delete_subscription/3, [JID, NodeID, SubID]) of - {atomic, Result} -> {result, Result}; - {aborted, Error} -> Error + {'EXIT', {aborted, Error}} -> Error; + Result -> {result, Result} end. get_subscription(JID, NodeID, SubID) -> - case mnesia:sync_dirty(fun read_subscription/3, + case catch mnesia:sync_dirty(fun read_subscription/3, [JID, NodeID, SubID]) of - {atomic, Result} -> {result, Result}; - {aborted, Error} -> Error + {'EXIT', {aborted, Error}} -> Error; + Result -> {result, Result} end. set_subscription(JID, NodeID, SubID, Options) -> - case mnesia:sync_dirty(fun write_subscription/4, + case catch mnesia:sync_dirty(fun write_subscription/4, [JID, NodeID, SubID, Options]) of - {atomic, Result} -> {result, Result}; - {aborted, Error} -> Error + {'EXIT', {aborted, Error}} -> Error; + Result -> {result, Result} end. get_options_xform(Lang, Options) ->