~ubuntu-branches/ubuntu/trusty/ejabberd/trusty-proposed

« back to all changes in this revision

Viewing changes to src/mod_pubsub/pubsub_odbc.patch

  • Committer: Bazaar Package Importer
  • Author(s): Konstantin Khomoutov, Konstantin Khomoutov
  • Date: 2010-08-03 19:55:25 UTC
  • mfrom: (1.1.16 upstream)
  • Revision ID: james.westby@ubuntu.com-20100803195525-dix2icz1w2fkew0n
Tags: 2.1.5-1
[ Konstantin Khomoutov ]
* New upstream release.
* Remove obsolete erlang-otp-r14-ssl.patch
* Refresh patches: reopen-log.patch, shared_roster_online.patch
  shared_roster_recent.patch
* Bump standards version to 3.9.0.
* Remove COPYING file installed by upstream Makefile
* Remove autogenerated src/ejabberd.init
* Add upstream patch fixing EJAB-1284 (closes: #591431).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
--- mod_pubsub.erl      2010-06-02 15:03:48.000000000 +0200
2
 
+++ mod_pubsub_odbc.erl 2010-06-02 16:45:38.000000000 +0200
 
1
--- mod_pubsub.erl      2010-08-02 16:07:28.000000000 +0200
 
2
+++ mod_pubsub_odbc.erl 2010-08-02 17:04:37.000000000 +0200
3
3
@@ -42,7 +42,7 @@
4
4
 %%% 6.2.3.1, 6.2.3.5, and 6.3. For information on subscription leases see
5
5
 %%% XEP-0060 section 12.18.
22
22
 
23
23
 %% exports for hooks
24
24
 -export([presence_probe/3,
25
 
@@ -104,7 +104,7 @@
 
25
@@ -103,7 +103,7 @@
26
26
         string_to_affiliation/1,
27
27
         extended_error/2,
28
28
         extended_error/3,
31
31
        ]).
32
32
 
33
33
 %% API and gen_server callbacks
34
 
@@ -123,7 +123,7 @@
 
34
@@ -122,7 +122,7 @@
35
35
 -export([send_loop/1
36
36
        ]).
37
37
 
40
40
 -define(LOOPNAME, ejabberd_mod_pubsub_loop).
41
41
 -define(PLUGIN_PREFIX, "node_").
42
42
 -define(TREE_PREFIX, "nodetree_").
43
 
@@ -220,8 +220,6 @@
 
43
@@ -217,8 +217,6 @@
44
44
            ok
45
45
     end,
46
46
     ejabberd_router:register_route(Host),
49
49
     init_nodes(Host, ServerHost, NodeTree, Plugins),
50
50
     State = #state{host = Host,
51
51
                server_host = ServerHost,
52
 
@@ -280,207 +278,14 @@
 
52
@@ -277,207 +275,14 @@
53
53
 
54
54
 init_nodes(Host, ServerHost, _NodeTree, Plugins) ->
55
55
     %% TODO, this call should be done plugin side
260
260
 send_loop(State) ->
261
261
     receive
262
262
     {presence, JID, Pid} ->
263
 
@@ -491,17 +296,15 @@
 
263
@@ -488,17 +293,15 @@
264
264
        %% for each node From is subscribed to
265
265
        %% and if the node is so configured, send the last published item to From
266
266
        lists:foreach(fun(PType) ->
284
284
                    true ->
285
285
                        % resource not concerned about that subscription
286
286
                        ok
287
 
@@ -747,10 +550,10 @@
 
287
@@ -617,7 +420,8 @@
 
288
 disco_identity(_Host, <<>>, _From) ->
 
289
     [{xmlelement, "identity", [{"category", "pubsub"}, {"type", "pep"}], []}];
 
290
 disco_identity(Host, Node, From) ->
 
291
-    Action = fun(#pubsub_node{id = Idx, type = Type, options = Options, owners = Owners}) ->
 
292
+    Action = fun(#pubsub_node{id = Idx, type = Type, options = Options}) ->
 
293
+           Owners = node_owners_call(Type, Idx),
 
294
            case get_allowed_items_call(Host, Idx, From, Type, Options, Owners) of
 
295
                {result, _} ->
 
296
                    {result, [{xmlelement, "identity", [{"category", "pubsub"}, {"type", "pep"}], []},
 
297
@@ -652,7 +456,8 @@
 
298
     [?NS_PUBSUB
 
299
     | [?NS_PUBSUB++"#"++Feature || Feature <- features("pep")]];
 
300
 disco_features(Host, Node, From) ->
 
301
-    Action = fun(#pubsub_node{id = Idx, type = Type, options = Options, owners = Owners}) ->
 
302
+    Action = fun(#pubsub_node{id = Idx, type = Type, options = Options}) ->
 
303
+           Owners = node_owners_call(Type, Idx),
 
304
            case get_allowed_items_call(Host, Idx, From, Type, Options, Owners) of
 
305
                {result, _} ->
 
306
                    {result, [?NS_PUBSUB
 
307
@@ -677,7 +482,8 @@
 
308
     Acc.
 
309
 
 
310
 disco_items(Host, <<>>, From) ->
 
311
-    Action = fun(#pubsub_node{nodeid ={_, NodeID}, options = Options, type = Type, id = Idx, owners = Owners}, Acc) ->
 
312
+    Action = fun(#pubsub_node{nodeid ={_, NodeID}, options = Options, type = Type, id = Idx}, Acc) ->
 
313
+               Owners = node_owners_call(Type, Idx),
 
314
                case get_allowed_items_call(Host, Idx, From, Type, Options, Owners) of
 
315
                    {result, _} ->
 
316
                        [{xmlelement, "item",
 
317
@@ -695,13 +501,14 @@
 
318
                    _ -> Acc
 
319
                end
 
320
            end,
 
321
-    case transaction(Host, Action, sync_dirty) of
 
322
+    case transaction_on_nodes(Host, Action, sync_dirty) of
 
323
        {result, Items} -> Items;
 
324
        _ -> []
 
325
     end;
 
326
 
 
327
 disco_items(Host, Node, From) ->
 
328
-    Action = fun(#pubsub_node{id = Idx, type = Type, options = Options, owners = Owners}) ->
 
329
+    Action = fun(#pubsub_node{id = Idx, type = Type, options = Options}) ->
 
330
+           Owners = node_owners_call(Type, Idx),
 
331
            case get_allowed_items_call(Host, Idx, From, Type, Options, Owners) of
 
332
                {result, Items} ->
 
333
                    {result, [{xmlelement, "item",
 
334
@@ -781,10 +588,10 @@
288
335
        lists:foreach(fun(PType) ->
289
336
            {result, Subscriptions} = node_action(Host, PType, get_entity_subscriptions, [Host, Entity]),
290
337
            lists:foreach(fun
297
344
                                true ->
298
345
                                    node_action(Host, PType, unsubscribe_node, [NodeId, Entity, JID, all]);
299
346
                                false ->
300
 
@@ -920,7 +723,8 @@
 
347
@@ -952,7 +759,8 @@
301
348
                            sub_el = SubEl} = IQ ->
302
349
                            {xmlelement, _, QAttrs, _} = SubEl,
303
350
                            Node = xml:get_attr_s("node", QAttrs),
307
354
                                      {result, IQRes} ->
308
355
                                          jlib:iq_to_xml(
309
356
                                            IQ#iq{type = result,
310
 
@@ -1033,7 +837,7 @@
 
357
@@ -1065,7 +873,7 @@
311
358
                                    [] ->
312
359
                                        ["leaf"]; %% No sub-nodes: it's a leaf node
313
360
                                    _ ->
316
363
                                            {result, []} -> ["collection"];
317
364
                                            {result, _} -> ["leaf", "collection"];
318
365
                                            _ -> []
319
 
@@ -1049,8 +853,9 @@
 
366
@@ -1081,8 +889,9 @@
320
367
                            [];
321
368
                        true ->
322
369
                            [{xmlelement, "feature", [{"var", ?NS_PUBSUB}], []} |
328
375
                                       end, features(Type))]
329
376
                    end,
330
377
                %% TODO: add meta-data info (spec section 5.4)
331
 
@@ -1079,8 +884,9 @@
 
378
@@ -1111,8 +920,9 @@
332
379
                {xmlelement, "feature", [{"var", ?NS_PUBSUB}], []},
333
380
                {xmlelement, "feature", [{"var", ?NS_COMMANDS}], []},
334
381
                {xmlelement, "feature", [{"var", ?NS_VCARD}], []}] ++
340
387
             end, features(Host, Node))};
341
388
         <<?NS_COMMANDS>> ->
342
389
             command_disco_info(Host, Node, From);
343
 
@@ -1090,7 +896,7 @@
 
390
@@ -1122,7 +932,7 @@
344
391
            node_disco_info(Host, Node, From)
345
392
     end.
346
393
 
349
396
     case tree_action(Host, get_subnodes, [Host, <<>>, From]) of
350
397
        Nodes when is_list(Nodes) ->
351
398
            {result, lists:map(
352
 
@@ -1107,14 +913,14 @@
 
399
@@ -1139,23 +949,24 @@
353
400
        Other ->
354
401
            Other
355
402
     end;
367
414
     case string:tokens(Item, "!") of
368
415
        [_SNode, _ItemID] ->
369
416
            {result, []};
370
 
@@ -1122,10 +928,10 @@
 
417
        [SNode] ->
371
418
            Node = string_to_node(SNode),
372
 
            Action =
373
 
                fun(#pubsub_node{type = Type, id = NodeId}) ->
374
 
-                       % TODO call get_items/6 instead for access control (EJAB-1033)
375
 
-                       NodeItems = case node_call(Type, get_items, [NodeId, From]) of
376
 
+                       %% TODO call get_items/6 instead for access control (EJAB-1033)
377
 
+                       {NodeItems, RsmOut} = case node_call(Type, get_items, [NodeId, From, RSM]) of
378
 
                                        {result, I} -> I;
379
 
-                                       _ -> []
380
 
+                                       _ -> {[], none}
381
 
                                    end,
 
419
-           Action = fun(#pubsub_node{id = Idx, type = Type, options = Options, owners = Owners}) ->
 
420
-                       NodeItems = case get_allowed_items_call(Host, Idx, From, Type, Options, Owners) of
 
421
+           Action = fun(#pubsub_node{id = Idx, type = Type, options = Options}) ->
 
422
+                       Owners = node_owners_call(Type, Idx),
 
423
+                       {NodeItems, RsmOut} = case get_allowed_items_call(Host, Idx, From, Type, Options, Owners, RSM) of
 
424
                            {result, R} -> R;
 
425
-                           _ -> []
 
426
+                           _ -> {[], none}
 
427
                            end,
382
428
                        Nodes = lists:map(
383
 
                                fun(#pubsub_node{nodeid = {_, SubNode}, options = Options}) ->
384
 
@@ -1143,7 +949,7 @@
 
429
                                fun(#pubsub_node{nodeid = {_, SubNode}, options = SubOptions}) ->
 
430
@@ -1173,7 +984,7 @@
385
431
                                    {result, Name} = node_call(Type, get_item_name, [Host, Node, RN]),
386
432
                                    {xmlelement, "item", [{"jid", Host}, {"name", Name}], []}
387
433
                                end, NodeItems),
390
436
                end,
391
437
            case transaction(Host, Node, Action, sync_dirty) of
392
438
                {result, {_, Result}} -> {result, Result};
393
 
@@ -1272,7 +1078,8 @@
 
439
@@ -1284,7 +1095,8 @@
394
440
                        (_, Acc) ->
395
441
                            Acc
396
442
                        end, [], xml:remove_cdata(Els)),
400
446
                {get, "subscriptions"} ->
401
447
                    get_subscriptions(Host, Node, From, Plugins);
402
448
                {get, "affiliations"} ->
403
 
@@ -1295,7 +1102,9 @@
 
449
@@ -1307,7 +1119,9 @@
404
450
 
405
451
 iq_pubsub_owner(Host, ServerHost, From, IQType, SubEl, Lang) ->
406
452
     {xmlelement, _, _, SubEls} = SubEl,
411
457
     case Action of
412
458
        [{xmlelement, Name, Attrs, Els}] ->
413
459
            Node = string_to_node(xml:get_attr_s("node", Attrs)),
414
 
@@ -1425,7 +1234,8 @@
 
460
@@ -1437,7 +1251,8 @@
415
461
                    _          -> []
416
462
                end
417
463
        end,
421
467
                     sync_dirty) of
422
468
        {result, Res} -> Res;
423
469
        Err        -> Err
424
 
@@ -1464,7 +1274,7 @@
 
470
@@ -1476,7 +1291,7 @@
425
471
 
426
472
 %%% authorization handling
427
473
 
430
476
     Lang = "en", %% TODO fix
431
477
     Stanza = {xmlelement, "message",
432
478
              [],
433
 
@@ -1493,7 +1303,7 @@
 
479
@@ -1505,7 +1320,7 @@
434
480
                  [{xmlelement, "value", [], [{xmlcdata, "false"}]}]}]}]},
435
481
     lists:foreach(fun(Owner) ->
436
482
        ejabberd_router:route(service_jid(Host), jlib:make_jid(Owner), Stanza)
439
485
 
440
486
 find_authorization_response(Packet) ->
441
487
     {xmlelement, _Name, _Attrs, Els} = Packet,
442
 
@@ -1557,8 +1367,8 @@
 
488
@@ -1569,8 +1384,8 @@
443
489
                        "true" -> true;
444
490
                        _ -> false
445
491
                    end,
450
496
                             {result, Subscriptions} = node_call(Type, get_subscriptions, [NodeId, Subscriber]),
451
497
                             if
452
498
                                 not IsApprover ->
453
 
@@ -1757,7 +1567,7 @@
 
499
@@ -1769,7 +1584,7 @@
454
500
            Reply = [{xmlelement, "pubsub", [{"xmlns", ?NS_PUBSUB}],
455
501
                      [{xmlelement, "create", nodeAttr(Node),
456
502
                        []}]}],
459
505
                {result, {NodeId, SubsByDepth, {Result, broadcast}}} ->
460
506
                    broadcast_created_node(Host, Node, NodeId, Type, NodeOptions, SubsByDepth),
461
507
                    case Result of
462
 
@@ -1860,7 +1670,7 @@
 
508
@@ -1872,7 +1687,7 @@
463
509
 %%<li>The node does not exist.</li>
464
510
 %%</ul>
465
511
 subscribe_node(Host, Node, From, JID, Configuration) ->
468
514
        {result, GoodSubOpts} -> GoodSubOpts;
469
515
        _ -> invalid
470
516
     end,
471
 
@@ -1868,7 +1678,7 @@
 
517
@@ -1880,7 +1695,7 @@
472
518
                     error -> {"", "", ""};
473
519
                     J -> jlib:jid_tolower(J)
474
520
                 end,
475
 
-    Action = fun(#pubsub_node{options = Options, owners = [Owner|_], type = Type, id = NodeId}) ->
 
521
-    Action = fun(#pubsub_node{options = Options, owners = Owners, type = Type, id = NodeId}) ->
476
522
+    Action = fun(#pubsub_node{options = Options, type = Type, id = NodeId}) ->
477
523
                    Features = features(Type),
478
524
                    SubscribeFeature = lists:member("subscribe", Features),
479
525
                    OptionsFeature = lists:member("subscription-options", Features),
480
 
@@ -1887,9 +1697,13 @@
481
 
                                    {"", "", ""} ->
482
 
                                        {false, false};
483
 
                                    _ ->
484
 
-                                       {OU, OS, _} = Owner,
485
 
-                                       get_roster_info(OU, OS,
486
 
-                                                       Subscriber, AllowedGroups)
487
 
+                                       case node_owners_call(Type, NodeId) of
488
 
+                                           [{OU, OS, _}|_] ->
489
 
+                                               get_roster_info(OU, OS,
490
 
+                                                               Subscriber, AllowedGroups);
491
 
+                                           _ ->
492
 
+                                               {false, false}
493
 
+                                       end
494
 
                                end
495
 
                        end,
 
526
@@ -1889,6 +1704,7 @@
 
527
                    AccessModel = get_option(Options, access_model),
 
528
                    SendLast = get_option(Options, send_last_published_item),
 
529
                    AllowedGroups = get_option(Options, roster_groups_allowed, []),
 
530
+                   Owners = node_owners_call(Type, NodeId),
 
531
                    {PresenceSubscription, RosterGroup} = get_presence_and_roster_permissions(Host, Subscriber, Owners, AccessModel, AllowedGroups),
496
532
                    if
497
 
@@ -2220,7 +2034,7 @@
 
533
                        not SubscribeFeature ->
 
534
@@ -2218,7 +2034,7 @@
498
535
 %% <p>The permission are not checked in this function.</p>
499
536
 %% @todo We probably need to check that the user doing the query has the right
500
537
 %% to read the items.
503
540
     MaxItems =
504
541
        if
505
542
            SMaxItems == "" -> get_max_items_node(Host);
506
 
@@ -2259,11 +2073,11 @@
 
543
@@ -2232,12 +2048,13 @@
 
544
        {error, Error} ->
 
545
            {error, Error};
 
546
        _ ->
 
547
-           Action = fun(#pubsub_node{options = Options, type = Type, id = NodeId, owners = Owners}) ->
 
548
+           Action = fun(#pubsub_node{options = Options, type = Type, id = NodeId}) ->
 
549
                     Features = features(Type),
 
550
                     RetreiveFeature = lists:member("retrieve-items", Features),
 
551
                     PersistentFeature = lists:member("persistent-items", Features),
 
552
                     AccessModel = get_option(Options, access_model),
 
553
                     AllowedGroups = get_option(Options, roster_groups_allowed, []),
 
554
+                    Owners = node_owners_call(Type, NodeId),
 
555
                     {PresenceSubscription, RosterGroup} = get_presence_and_roster_permissions(Host, From, Owners, AccessModel, AllowedGroups),
 
556
                     if
 
557
                         not RetreiveFeature ->
 
558
@@ -2250,11 +2067,11 @@
507
559
                             node_call(Type, get_items,
508
560
                                       [NodeId, From,
509
561
                                        AccessModel, PresenceSubscription, RosterGroup,
517
569
                    SendItems = case ItemIDs of
518
570
                        [] -> 
519
571
                            Items;
520
 
@@ -2276,7 +2090,8 @@
 
572
@@ -2267,7 +2084,8 @@
521
573
                    %% number of items sent to MaxItems:
522
574
                    {result, [{xmlelement, "pubsub", [{"xmlns", ?NS_PUBSUB}],
523
575
                                [{xmlelement, "items", nodeAttr(Node),
527
579
                Error ->
528
580
                    Error
529
581
            end
530
 
@@ -2308,16 +2123,27 @@
 
582
@@ -2289,10 +2107,15 @@
 
583
        Error -> Error
 
584
     end.
 
585
 get_allowed_items_call(Host, NodeIdx, From, Type, Options, Owners) ->
 
586
+    case get_allowed_items_call(Host, NodeIdx, From, Type, Options, Owners, none) of
 
587
+       {result, {I, _}} -> {result, I};
 
588
+       Error -> Error
 
589
+    end.
 
590
+get_allowed_items_call(Host, NodeIdx, From, Type, Options, Owners, RSM) ->
 
591
     AccessModel = get_option(Options, access_model),
 
592
     AllowedGroups = get_option(Options, roster_groups_allowed, []),
 
593
     {PresenceSubscription, RosterGroup} = get_presence_and_roster_permissions(Host, From, Owners, AccessModel, AllowedGroups),
 
594
-    node_call(Type, get_items, [NodeIdx, From, AccessModel, PresenceSubscription, RosterGroup, undefined]).
 
595
+    node_call(Type, get_items, [NodeIdx, From, AccessModel, PresenceSubscription, RosterGroup, undefined, RSM]).
 
596
 
 
597
 
 
598
 %% @spec (Host, Node, NodeId, Type, LJID, Number) -> any()
 
599
@@ -2305,16 +2128,27 @@
531
600
 %% @doc <p>Resend the items of a node to the user.</p>
532
601
 %% @todo use cache-last-item feature
533
602
 send_items(Host, Node, NodeId, Type, LJID, last) ->
561
630
 send_items(Host, Node, NodeId, Type, LJID, Number) ->
562
631
     ToSend = case node_action(Host, Type, get_items, [NodeId, LJID]) of
563
632
        {result, []} -> 
564
 
@@ -2443,7 +2269,8 @@
 
633
@@ -2440,7 +2274,8 @@
565
634
        error ->
566
635
            {error, ?ERR_BAD_REQUEST};
567
636
        _ ->
571
640
                        case lists:member(Owner, Owners) of
572
641
                            true ->
573
642
                                OwnerJID = jlib:make_jid(Owner),
574
 
@@ -2453,24 +2280,7 @@
 
643
@@ -2450,24 +2285,7 @@
575
644
                                    end,
576
645
                                lists:foreach(
577
646
                                    fun({JID, Affiliation}) ->
597
666
                                    end, FilteredEntities),
598
667
                                {result, []};
599
668
                            _ ->
600
 
@@ -2523,11 +2333,11 @@
 
669
@@ -2520,11 +2338,11 @@
601
670
     end.
602
671
 
603
672
 read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
611
680
            OptionsEl = {xmlelement, "options", [{"jid", jlib:jid_to_string(Subscriber)},
612
681
                                                 {"subid", SubID}|nodeAttr(Node)],
613
682
                         [XdataEl]},
614
 
@@ -2553,7 +2363,7 @@
 
683
@@ -2550,7 +2368,7 @@
615
684
     end.
616
685
 
617
686
 set_options_helper(Configuration, JID, NodeID, SubID, Type) ->
620
689
        {result, GoodSubOpts} -> GoodSubOpts;
621
690
        _ -> invalid
622
691
     end,
623
 
@@ -2582,7 +2392,7 @@
 
692
@@ -2579,7 +2397,7 @@
624
693
 write_sub(_Subscriber, _NodeID, _SubID, invalid) ->
625
694
     {error, extended_error(?ERR_BAD_REQUEST, "invalid-options")};
626
695
 write_sub(Subscriber, NodeID, SubID, Options) ->
629
698
        {error, notfound} ->
630
699
            {error, extended_error(?ERR_NOT_ACCEPTABLE, "invalid-subid")};
631
700
        {result, _} ->
632
 
@@ -2750,8 +2560,8 @@
 
701
@@ -2747,8 +2565,8 @@
633
702
                                     {"subscription", subscription_to_string(Sub)} | nodeAttr(Node)], []}]}]},
634
703
                ejabberd_router:route(service_jid(Host), jlib:make_jid(JID), Stanza)
635
704
            end,
640
709
                                true ->
641
710
                                    Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
642
711
 
643
 
@@ -3088,7 +2898,7 @@
 
712
@@ -3103,7 +2921,7 @@
644
713
                        {Depth, [{N, get_node_subs(N)} || N <- Nodes]}
645
714
            end, tree_call(Host, get_parentnodes_tree, [Host, Node, service_jid(Host)]))}
646
715
        end,
649
718
        {result, CollSubs} -> CollSubs;
650
719
        _ -> []
651
720
     end.
652
 
@@ -3102,9 +2912,9 @@
 
721
@@ -3117,9 +2935,9 @@
653
722
 
654
723
 get_options_for_subs(NodeID, Subs) ->
655
724
     lists:foldl(fun({JID, subscribed, SubID}, Acc) ->
661
730
                            _ -> Acc
662
731
                        end;
663
732
                    (_, Acc) ->
664
 
@@ -3308,6 +3118,30 @@
 
733
@@ -3323,6 +3141,30 @@
665
734
            Result
666
735
     end.
667
736
 
692
761
 %% @spec (Host, Options) -> MaxItems
693
762
 %%      Host = host()
694
763
 %%      Options = [Option]
695
 
@@ -3704,7 +3538,13 @@
 
764
@@ -3719,7 +3561,13 @@
696
765
 tree_action(Host, Function, Args) ->
697
766
     ?DEBUG("tree_action ~p ~p ~p",[Host,Function,Args]),
698
767
     Fun = fun() -> tree_call(Host, Function, Args) end,
707
776
 
708
777
 %% @doc <p>node plugin call.</p>
709
778
 node_call(Type, Function, Args) ->
710
 
@@ -3724,13 +3564,13 @@
 
779
@@ -3739,13 +3587,13 @@
711
780
 
712
781
 node_action(Host, Type, Function, Args) ->
713
782
     ?DEBUG("node_action ~p ~p ~p ~p",[Host,Type,Function,Args]),
723
792
                        case tree_call(Host, get_node, [Host, Node]) of
724
793
                            N when is_record(N, pubsub_node) ->
725
794
                                case Action(N) of
726
 
@@ -3743,8 +3583,14 @@
 
795
@@ -3757,13 +3605,19 @@
 
796
                                Error
727
797
                        end
728
798
                end, Trans).
 
799
-transaction(Host, Action, Trans) ->
 
800
-    transaction(fun() ->
 
801
+transaction_on_nodes(Host, Action, Trans) ->
 
802
+    transaction(Host, fun() ->
 
803
                        {result, lists:foldl(Action, [], tree_call(Host, get_nodes, [Host]))}
 
804
                end, Trans).
729
805
 
730
806
-transaction(Fun, Trans) ->
731
807
-    case catch mnesia:Trans(Fun) of
740
816
        {result, Result} -> {result, Result};
741
817
        {error, Error} -> {error, Error};
742
818
        {atomic, {result, Result}} -> {result, Result};
743
 
@@ -3752,6 +3598,15 @@
 
819
@@ -3771,6 +3625,15 @@
744
820
        {aborted, Reason} ->
745
821
            ?ERROR_MSG("transaction return internal error: ~p~n", [{aborted, Reason}]),
746
822
            {error, ?ERR_INTERNAL_SERVER_ERROR};
756
832
        {'EXIT', Reason} ->
757
833
            ?ERROR_MSG("transaction return internal error: ~p~n", [{'EXIT', Reason}]),
758
834
            {error, ?ERR_INTERNAL_SERVER_ERROR};
759
 
@@ -3760,6 +3615,17 @@
 
835
@@ -3779,6 +3642,17 @@
760
836
            {error, ?ERR_INTERNAL_SERVER_ERROR}
761
837
     end.
762
838