aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mnesia/src/mnesia.erl
diff options
context:
space:
mode:
authorDániel Szoboszlay <[email protected]>2016-10-06 10:20:41 +0200
committerDániel Szoboszlay <[email protected]>2016-10-06 10:20:41 +0200
commit1b4969db6ca0062f629f58c8d3838bcca1ab326b (patch)
tree855c8ec971ac8f3cea36d90836048f71527c3d87 /lib/mnesia/src/mnesia.erl
parentdabc6644991a6e732dc4404433215d1333a0ea07 (diff)
downloadotp-1b4969db6ca0062f629f58c8d3838bcca1ab326b.tar.gz
otp-1b4969db6ca0062f629f58c8d3838bcca1ab326b.tar.bz2
otp-1b4969db6ca0062f629f58c8d3838bcca1ab326b.zip
Allow reusing mnesia select continuations
A continuation returned by mnesia:select/[14] should be reusable in different, non-transactional activities. Aborting with wrong_transaction doesn't make sense in a dirty context.
Diffstat (limited to 'lib/mnesia/src/mnesia.erl')
-rw-r--r--lib/mnesia/src/mnesia.erl8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/mnesia/src/mnesia.erl b/lib/mnesia/src/mnesia.erl
index 9586adbf93..5bf2fc2dc3 100644
--- a/lib/mnesia/src/mnesia.erl
+++ b/lib/mnesia/src/mnesia.erl
@@ -1409,8 +1409,14 @@ select_cont(Tid,_,State=#mnesia_select{tid=Tid,written=[]}) ->
select_state(dirty_sel_cont(State),State);
select_cont(Tid,_Ts,State=#mnesia_select{tid=Tid}) ->
trans_select(dirty_sel_cont(State), State);
-select_cont(_Tid2,_,#mnesia_select{tid=_Tid1}) -> % Missmatching tids
+select_cont(Tid2,_,#mnesia_select{tid=_Tid1})
+ when element(1,Tid2) == tid -> % Mismatching tids
abort(wrong_transaction);
+select_cont(Tid,Ts,State=#mnesia_select{}) ->
+ % Repair mismatching tids in non-transactional contexts
+ RepairedState = State#mnesia_select{tid = Tid, written = [],
+ spec = undefined, type = undefined},
+ select_cont(Tid,Ts,RepairedState);
select_cont(_,_,Cont) ->
abort({badarg, Cont}).