aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorUlf Wiger <[email protected]>2010-12-14 19:27:26 +0100
committerHenrik Nord <[email protected]>2011-05-16 11:00:28 +0200
commitb10094bc2f120ceda0e927d31067670e26a0a4d7 (patch)
tree878ea2c14ca73b11230850e5382d337b5108ea1a /lib
parent5309d521c394aa7ca1feb679dbda6333a3cb4873 (diff)
downloadotp-b10094bc2f120ceda0e927d31067670e26a0a4d7.tar.gz
otp-b10094bc2f120ceda0e927d31067670e26a0a4d7.tar.bz2
otp-b10094bc2f120ceda0e927d31067670e26a0a4d7.zip
optimize sticky_lock maj. check
Diffstat (limited to 'lib')
-rw-r--r--lib/mnesia/src/mnesia_locker.erl14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/mnesia/src/mnesia_locker.erl b/lib/mnesia/src/mnesia_locker.erl
index 2025a2ab37..635668ff59 100644
--- a/lib/mnesia/src/mnesia_locker.erl
+++ b/lib/mnesia/src/mnesia_locker.erl
@@ -733,13 +733,14 @@ sticky_lock(Tid, Store, {Tab, Key} = Oid, Lock) ->
end.
do_sticky_lock(Tid, Store, {Tab, Key} = Oid, Lock) ->
- sticky_check_majority(Lock, Tab),
+ WNodes = w_nodes(Tab),
+ sticky_check_majority(Lock, Tab, WNodes),
?MODULE ! {self(), {test_set_sticky, Tid, Oid, Lock}},
N = node(),
receive
{?MODULE, N, granted} ->
?ets_insert(Store, {{locks, Tab, Key}, write}),
- [?ets_insert(Store, {nodes, Node}) || Node <- w_nodes(Tab)],
+ [?ets_insert(Store, {nodes, Node}) || Node <- WNodes],
granted;
{?MODULE, N, {granted, Val}} -> %% for rwlocks
case opt_lookup_in_client(Val, Oid, write) of
@@ -747,7 +748,7 @@ do_sticky_lock(Tid, Store, {Tab, Key} = Oid, Lock) ->
exit({aborted, C});
Val2 ->
?ets_insert(Store, {{locks, Tab, Key}, write}),
- [?ets_insert(Store, {nodes, Node}) || Node <- w_nodes(Tab)],
+ [?ets_insert(Store, {nodes, Node}) || Node <- WNodes],
Val2
end;
{?MODULE, N, {not_granted, Reason}} ->
@@ -763,13 +764,12 @@ do_sticky_lock(Tid, Store, {Tab, Key} = Oid, Lock) ->
dirty_sticky_lock(Tab, Key, [N], Lock)
end.
-sticky_check_majority(read, _) ->
+sticky_check_majority(read, _, _) ->
ok;
-sticky_check_majority(write, Tab) ->
+sticky_check_majority(write, Tab, WNodes) ->
case ?catch_val({Tab, majority}) of
true ->
- HaveNodes = val({Tab, where_to_write}),
- case mnesia_lib:have_majority(Tab, HaveNodes) of
+ case mnesia_lib:have_majority(Tab, WNodes) of
true ->
ok;
false ->