aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mnesia/src
diff options
context:
space:
mode:
authorMagnus Fröberg <[email protected]>2018-11-28 11:59:19 +0100
committerRichard Carlsson <[email protected]>2018-11-29 08:56:37 +0100
commit8332bff4ceebd08d103623f59f7761d8e9367f69 (patch)
tree86bc2e8bac296609c2f5d47cd4526debed6cab88 /lib/mnesia/src
parent482cde369a02391b30511e10fb24a1a836d643e8 (diff)
downloadotp-8332bff4ceebd08d103623f59f7761d8e9367f69.tar.gz
otp-8332bff4ceebd08d103623f59f7761d8e9367f69.tar.bz2
otp-8332bff4ceebd08d103623f59f7761d8e9367f69.zip
Fall back to default locking if LockKind is not read or write
Diffstat (limited to 'lib/mnesia/src')
-rw-r--r--lib/mnesia/src/mnesia.erl10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/mnesia/src/mnesia.erl b/lib/mnesia/src/mnesia.erl
index 89b7207483..77afb8250c 100644
--- a/lib/mnesia/src/mnesia.erl
+++ b/lib/mnesia/src/mnesia.erl
@@ -851,7 +851,7 @@ read(Tid, Ts, Tab, Key, LockKind)
abort({bad_type, Tab, LockKind})
end
end,
- add_written(?ets_lookup(Store, Oid), Tab, ObjsFun);
+ add_written(?ets_lookup(Store, Oid), Tab, ObjsFun, LockKind);
_Protocol ->
dirty_read(Tab, Key)
end;
@@ -1207,13 +1207,17 @@ add_previous(_Tid, Ts, _Type, Tab) ->
%% The actual read from the table is not done if not needed due to local
%% transaction context, and if so, no extra read lock is needed either.
-add_written([], _Tab, ObjsFun) ->
+add_written([], _Tab, ObjsFun, _LockKind) ->
ObjsFun(); % standard normal fast case
-add_written(Written, Tab, ObjsFun) ->
+add_written(Written, Tab, ObjsFun, LockKind) ->
case val({Tab, setorbag}) of
bag ->
add_written_to_bag(Written, ObjsFun(), []);
+ _ when LockKind == read;
+ LockKind == write ->
+ add_written_to_set(Written);
_ ->
+ _ = ObjsFun(), % Fall back to request new lock and read from source
add_written_to_set(Written)
end.