~ubuntu-branches/ubuntu/trusty/erlang/trusty

« back to all changes in this revision

Viewing changes to lib/mnesia/src/mnesia_subscr.erl

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2011-05-05 15:48:43 UTC
  • mfrom: (3.5.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110505154843-0om6ekzg6m7ugj27
Tags: 1:14.b.2-dfsg-3ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Drop libwxgtk2.8-dev build dependency. Wx isn't in main, and not
    supposed to.
  - Drop erlang-wx binary.
  - Drop erlang-wx dependency from -megaco, -common-test, and -reltool, they
    do not really need wx. Also drop it from -debugger; the GUI needs wx,
    but it apparently has CLI bits as well, and is also needed by -megaco,
    so let's keep the package for now.
  - debian/patches/series: Do what I meant, and enable build-options.patch
    instead.
* Additional changes:
  - Drop erlang-wx from -et
* Dropped Changes:
  - patches/pcre-crash.patch: CVE-2008-2371: outer level option with
    alternatives caused crash. (Applied Upstream)
  - fix for ssl certificate verification in newSSL: 
    ssl_cacertfile_fix.patch (Applied Upstream)
  - debian/patches/series: Enable native.patch again, to get stripped beam
    files and reduce the package size again. (build-options is what
    actually accomplished this)
  - Remove build-options.patch on advice from upstream and because it caused
    odd build failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
%%
2
2
%% %CopyrightBegin%
3
 
%% 
4
 
%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
5
 
%% 
 
3
%%
 
4
%% Copyright Ericsson AB 1997-2010. All Rights Reserved.
 
5
%%
6
6
%% The contents of this file are subject to the Erlang Public License,
7
7
%% Version 1.1, (the "License"); you may not use this file except in
8
8
%% compliance with the License. You should have received a copy of the
9
9
%% Erlang Public License along with this software. If not, it can be
10
10
%% retrieved online at http://www.erlang.org/.
11
 
%% 
 
11
%%
12
12
%% Software distributed under the License is distributed on an "AS IS"
13
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
14
%% the License for the specific language governing rights and limitations
15
15
%% under the License.
16
 
%% 
 
16
%%
17
17
%% %CopyrightEnd%
18
18
%%
19
19
 
30
30
         subscribers/0,
31
31
         report_table_event/4,
32
32
         report_table_event/5, 
33
 
         report_table_event/6
 
33
         report_table_event/6,
 
34
         report_activity/1
34
35
        ]).
35
36
 
36
37
%% gen_server callbacks
42
43
         code_change/3
43
44
        ]).
44
45
 
 
46
-compile({no_auto_import,[error/2]}).
 
47
 
45
48
-include("mnesia.hrl").
46
49
 
47
50
-import(mnesia_lib, [error/2]).
91
94
 
92
95
subscribe(ClientPid, system) ->
93
96
    change_subscr(activate, ClientPid, system);
 
97
subscribe(ClientPid, activity) ->
 
98
    change_subscr(activate, ClientPid, activity);
94
99
subscribe(ClientPid, {table, Tab}) ->
95
100
    change_subscr(activate, ClientPid, {table, Tab, simple});
96
101
subscribe(ClientPid, {table, Tab, simple}) ->
102
107
 
103
108
unsubscribe(ClientPid, system) ->
104
109
    change_subscr(deactivate, ClientPid, system);
 
110
unsubscribe(ClientPid, activity) ->
 
111
    change_subscr(deactivate, ClientPid, activity);
105
112
unsubscribe(ClientPid, {table, Tab}) ->
106
113
    change_subscr(deactivate, ClientPid, {table, Tab, simple});
107
114
unsubscribe(ClientPid, {table, Tab, simple}) ->
120
127
subscribers() ->
121
128
    [whereis(mnesia_event) | mnesia_lib:val(subscribers)].
122
129
 
 
130
report_activity({dirty, _pid}) -> 
 
131
    ok;
 
132
report_activity(Tid) ->
 
133
    case ?catch_val(activity_subscribers) of
 
134
        {'EXIT', _} -> ok;
 
135
        Subscribers ->
 
136
            deliver(Subscribers, {mnesia_activity_event, {complete, Tid}})
 
137
        end.
 
138
 
123
139
report_table_event(Tab, Tid, Obj, Op) ->   
124
140
    case ?catch_val({Tab, commit_work}) of
125
141
        {'EXIT', _} -> ok;
300
316
do_change({activate, ClientPid, system}, SubscrTab) when is_pid(ClientPid) ->
301
317
    Var = subscribers,
302
318
    activate(ClientPid, system, Var, subscribers(), SubscrTab);
 
319
do_change({activate, ClientPid, activity}, SubscrTab) when is_pid(ClientPid) ->
 
320
    Var = activity_subscribers,
 
321
    activate(ClientPid, activity, Var, mnesia_lib:val(Var), SubscrTab);
303
322
do_change({activate, ClientPid, {table, Tab, How}}, SubscrTab) when is_pid(ClientPid) ->
304
323
    case ?catch_val({Tab, where_to_read}) of
305
324
        Node when Node == node() ->
313
332
do_change({deactivate, ClientPid, system}, SubscrTab) ->
314
333
    Var = subscribers,
315
334
    deactivate(ClientPid, system, Var, SubscrTab);
 
335
do_change({deactivate, ClientPid, activity}, SubscrTab) ->
 
336
    Var = activity_subscribers,
 
337
    deactivate(ClientPid, activity, Var, SubscrTab);
316
338
do_change({deactivate, ClientPid, {table, Tab, How}}, SubscrTab) ->
317
339
    Var = {Tab, commit_work},
318
340
    deactivate(ClientPid, {table, Tab, How}, Var, SubscrTab);
345
367
 
346
368
activate(ClientPid, What, Var, OldSubscribers, SubscrTab) ->
347
369
    Old = 
348
 
        if Var == subscribers -> 
 
370
        if Var == subscribers orelse Var == activity_subscribers ->
349
371
                OldSubscribers;
350
372
           true -> 
351
373
                case lists:keysearch(subscribers, 1, OldSubscribers) of
379
401
add_subscr(subscribers, _What, Pid) ->
380
402
    mnesia_lib:add(subscribers, Pid),
381
403
    {ok, node()};
 
404
add_subscr(activity_subscribers, _What, Pid) ->
 
405
    mnesia_lib:add(activity_subscribers, Pid),
 
406
    {ok, node()};
382
407
add_subscr({Tab, commit_work}, What, Pid) ->
383
408
    Commit = mnesia_lib:val({Tab, commit_work}),
384
409
    case lists:keysearch(subscribers, 1, Commit) of
427
452
 
428
453
del_subscr(subscribers, _What, Pid) ->
429
454
    mnesia_lib:del(subscribers, Pid);
 
455
del_subscr(activity_subscribers, _What, Pid) ->
 
456
    mnesia_lib:del(activity_subscribers, Pid);
430
457
del_subscr({Tab, commit_work}, What, Pid) ->
431
458
    Commit = mnesia_lib:val({Tab, commit_work}),
432
459
    case lists:keysearch(subscribers, 1, Commit) of
473
500
    case What of
474
501
        system ->
475
502
            del_subscr(subscribers, What, ClientPid);
 
503
        activity ->
 
504
            del_subscr(activity_subscribers, What, ClientPid);
476
505
        {_, Tab, _Level} ->
477
506
            del_subscr({Tab, commit_work}, What, ClientPid)    
478
507
    end,