diff options
author | Hans Bolinder <[email protected]> | 2016-01-25 10:35:20 +0100 |
---|---|---|
committer | Hans Bolinder <[email protected]> | 2016-01-26 08:54:27 +0100 |
commit | 332d61900b466c3bb9f3892d272043e2ad3ffb90 (patch) | |
tree | 791a680b9cf78709cdfe407b25180f6db63b11d0 /lib/stdlib/src/dets.erl | |
parent | fe2d78e98e01fb8a596bd6816e2f154a2d5cfdd0 (diff) | |
download | otp-332d61900b466c3bb9f3892d272043e2ad3ffb90.tar.gz otp-332d61900b466c3bb9f3892d272043e2ad3ffb90.tar.bz2 otp-332d61900b466c3bb9f3892d272043e2ad3ffb90.zip |
Fix a race bug affecting dets_SUITE:open_file/2
The Dets server pretends the file is open before internal_open()
has been called, which means that unless the internal_open
message is applied first, other processes can find the pid by
calling dets_server:get_pid() and do things before Head has been
initialized properly.
Diffstat (limited to 'lib/stdlib/src/dets.erl')
-rw-r--r-- | lib/stdlib/src/dets.erl | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/stdlib/src/dets.erl b/lib/stdlib/src/dets.erl index 7036316242..6887bda67c 100644 --- a/lib/stdlib/src/dets.erl +++ b/lib/stdlib/src/dets.erl @@ -1291,7 +1291,15 @@ init(Parent, Server) -> open_file_loop(#head{parent = Parent, server = Server}). open_file_loop(Head) -> - open_file_loop(Head, 0). + %% The Dets server pretends the file is open before + %% internal_open() has been called, which means that unless the + %% internal_open message is applied first, other processes can + %% find the pid by calling dets_server:get_pid() and do things + %% before Head has been initialized properly. + receive + ?DETS_CALL(From, {internal_open, _Ref, _Args}=Op) -> + do_apply_op(Op, From, Head, 0) + end. open_file_loop(Head, N) when element(1, Head#head.update_mode) =:= error -> open_file_loop2(Head, N); |