aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mnesia/src
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2012-01-12 11:54:09 +0100
committerDan Gudmundsson <[email protected]>2012-01-31 15:26:27 +0100
commite9072b356cc917cacbffabc5086eb7d880ec5bb2 (patch)
tree6a87fba4d2f41d62ec08287a1ce0f7f5cb4aaeb4 /lib/mnesia/src
parent0c6d10bf1ee4a46c0d84a18fa99f1d99c144906a (diff)
downloadotp-e9072b356cc917cacbffabc5086eb7d880ec5bb2.tar.gz
otp-e9072b356cc917cacbffabc5086eb7d880ec5bb2.tar.bz2
otp-e9072b356cc917cacbffabc5086eb7d880ec5bb2.zip
[Mnesia] More optimizations
If a transaction releases a write, it can be deleted directly since no read locks or other write locks can be present
Diffstat (limited to 'lib/mnesia/src')
-rw-r--r--lib/mnesia/src/mnesia_locker.erl23
1 files changed, 8 insertions, 15 deletions
diff --git a/lib/mnesia/src/mnesia_locker.erl b/lib/mnesia/src/mnesia_locker.erl
index a9eb27dea2..a22c95d454 100644
--- a/lib/mnesia/src/mnesia_locker.erl
+++ b/lib/mnesia/src/mnesia_locker.erl
@@ -531,23 +531,16 @@ release_locks([]) ->
release_lock({Tid, Oid, {queued, _}}) ->
?ets_match_delete(mnesia_lock_queue, #queue{oid=Oid, tid = Tid, op = '_',
pid = '_', lucky = '_'});
-release_lock({Tid, Oid, Op}) ->
+release_lock({_Tid, Oid, write}) ->
+ ?ets_delete(mnesia_held_locks, Oid);
+release_lock({Tid, Oid, read}) ->
case ?ets_lookup(mnesia_held_locks, Oid) of
- [] -> ok;
[{Oid, Prev, Locks0}] ->
- Locks = remove_tid(Locks0, Tid, []),
- if Locks =:= [] ->
- ?ets_delete(mnesia_held_locks, Oid);
- Op =:= read ->
- ?ets_insert(mnesia_held_locks, {Oid, Prev, Locks});
- true ->
- case lists:any(fun({TOp, _}) -> TOp =:= write end, Locks) of
- true ->
- ?ets_insert(mnesia_held_locks, {Oid, write, Locks});
- false ->
- ?ets_insert(mnesia_held_locks, {Oid, read, Locks})
- end
- end
+ case remove_tid(Locks0, Tid, []) of
+ [] -> ?ets_delete(mnesia_held_locks, Oid);
+ Locks -> ?ets_insert(mnesia_held_locks, {Oid, Prev, Locks})
+ end;
+ [] -> ok
end.
remove_tid([{_Op, Tid}|Ls], Tid, Acc) ->