aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mnesia/src/mnesia_bup.erl
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2015-10-05 11:00:50 +0200
committerErlang/OTP <[email protected]>2015-10-05 11:00:50 +0200
commit192c247af496b6b33775cfad21b8cebdadd96823 (patch)
tree3cf6bf162214d68d024764b44a42d6b0bbe540b8 /lib/mnesia/src/mnesia_bup.erl
parent387eed25bdf60098dd7972c674fb2a982686c220 (diff)
parentd22396bce11debcbb6d8826468bd111ac0efbf7b (diff)
downloadotp-192c247af496b6b33775cfad21b8cebdadd96823.tar.gz
otp-192c247af496b6b33775cfad21b8cebdadd96823.tar.bz2
otp-192c247af496b6b33775cfad21b8cebdadd96823.zip
Merge branch 'dgud/mnesia/restore-leak/OTP-13025' into maint-18
* dgud/mnesia/restore-leak/OTP-13025: mnesia: Fix mnesia:restore/2 which caused a disk_log leak
Diffstat (limited to 'lib/mnesia/src/mnesia_bup.erl')
-rw-r--r--lib/mnesia/src/mnesia_bup.erl14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/mnesia/src/mnesia_bup.erl b/lib/mnesia/src/mnesia_bup.erl
index 0e653f2bc4..1f150ae38b 100644
--- a/lib/mnesia/src/mnesia_bup.erl
+++ b/lib/mnesia/src/mnesia_bup.erl
@@ -157,10 +157,11 @@ fallback_to_schema(Fname) ->
read_schema(Mod, Opaque) ->
R = #restore{bup_module = Mod, bup_data = Opaque},
try read_schema_section(R) of
- {_, {_Header, Schema, _}} -> Schema
+ {R2, {_Header, Schema, _}} ->
+ close_read(R2),
+ Schema
catch throw:{error,_} = Error ->
Error
- after close_read(R)
end.
%% Open backup media and extract schema
@@ -173,8 +174,13 @@ read_schema_section(R) ->
do_read_schema_section(R) ->
R2 = safe_apply(R, open_read, [R#restore.bup_data]),
- {R3, RawSchema} = safe_apply(R2, read, [R2#restore.bup_data]),
- do_read_schema_section(R3, verify_header(RawSchema), []).
+ try
+ {R3, RawSchema} = safe_apply(R2, read, [R2#restore.bup_data]),
+ do_read_schema_section(R3, verify_header(RawSchema), [])
+ catch T:E ->
+ close_read(R2),
+ erlang:raise(T,E,erlang:get_stacktrace())
+ end.
do_read_schema_section(R, {ok, B, C, []}, Acc) ->
case safe_apply(R, read, [R#restore.bup_data]) of