aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/dets.erl
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2013-03-08 15:31:58 +0100
committerHans Bolinder <[email protected]>2013-03-18 16:26:34 +0100
commitb5c571f17a680d3481b43194e6648a03192b2397 (patch)
treecc8ca95561f409af9686e9f477067be021920d8d /lib/stdlib/src/dets.erl
parentc1d0091cefb5d0b4c2984ec885576fbcb76dcb7d (diff)
downloadotp-b5c571f17a680d3481b43194e6648a03192b2397.tar.gz
otp-b5c571f17a680d3481b43194e6648a03192b2397.tar.bz2
otp-b5c571f17a680d3481b43194e6648a03192b2397.zip
Adjust dets.erl to cope with an evil test case
The test case deletes a Dets process while it is repairing a file. Another client waiting for the Dets process to reply then kicks in and repairs the file. Apparently the temporary file was still open, resulting in an eacces error on Windows.
Diffstat (limited to 'lib/stdlib/src/dets.erl')
-rw-r--r--lib/stdlib/src/dets.erl14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/stdlib/src/dets.erl b/lib/stdlib/src/dets.erl
index ecb509f4b5..45aef0ea80 100644
--- a/lib/stdlib/src/dets.erl
+++ b/lib/stdlib/src/dets.erl
@@ -2837,14 +2837,18 @@ fsck_try(Fd, Tab, FH, Fname, SlotNumbers, Version) ->
tempfile(Fname) ->
Tmp = lists:concat([Fname, ".TMP"]),
+ tempfile(Tmp, 10).
+
+tempfile(Tmp, 0) ->
+ Tmp;
+tempfile(Tmp, N) ->
case file:delete(Tmp) of
{error, eacces} -> % 'dets_process_died' happened anyway... (W-nd-ws)
- timer:sleep(5000),
- file:delete(Tmp);
+ timer:sleep(1000),
+ tempfile(Tmp, N-1);
_ ->
- ok
- end,
- Tmp.
+ Tmp
+ end.
%% -> {ok, NewHead} | {try_again, integer()} | Error
fsck_try_est(Head, Fd, Fname, SlotNumbers, FH) ->