diff options
author | Micael Karlberg <[email protected]> | 2011-04-01 12:07:23 +0200 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2011-04-01 12:07:23 +0200 |
commit | 2b46b0e42fe95d99619ffa343537c8468e27295c (patch) | |
tree | 9f01a4f4a6ad597299aa5a74e5e50a58e9d5812b /lib/stdlib/src/log_mf_h.erl | |
parent | 537f010d6fe871d55c3becb02fe6ebb73dc2d55a (diff) | |
parent | 49737813349f164b35737eb3cd59491930128f58 (diff) | |
download | otp-2b46b0e42fe95d99619ffa343537c8468e27295c.tar.gz otp-2b46b0e42fe95d99619ffa343537c8468e27295c.tar.bz2 otp-2b46b0e42fe95d99619ffa343537c8468e27295c.zip |
Merge branch 'bmk/snmp/manager/deprecate_old_api/OTP-9174' into bmk/snmp/snmp420_integration
Conflicts:
lib/snmp/doc/src/notes.xml
lib/snmp/src/app/snmp.appup.src
Diffstat (limited to 'lib/stdlib/src/log_mf_h.erl')
-rw-r--r-- | lib/stdlib/src/log_mf_h.erl | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/stdlib/src/log_mf_h.erl b/lib/stdlib/src/log_mf_h.erl index 2729f27e51..5fa5360fa1 100644 --- a/lib/stdlib/src/log_mf_h.erl +++ b/lib/stdlib/src/log_mf_h.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2009. All Rights Reserved. +%% Copyright Ericsson AB 1996-2011. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -185,13 +185,19 @@ read_index_file(Dir) -> %%----------------------------------------------------------------- %% Write the index file. This file contains one binary with %% the last used filename (an integer). +%% Write a temporary file and rename it in order to make the update +%% atomic. %%----------------------------------------------------------------- write_index_file(Dir, Index) -> - case file:open(Dir ++ "/index", [raw, write]) of + File = Dir ++ "/index", + TmpFile = File ++ ".tmp", + case file:open(TmpFile, [raw, write]) of {ok, Fd} -> - file:write(Fd, [Index]), - ok = file:close(Fd); + ok = file:write(Fd, [Index]), + ok = file:close(Fd), + ok = file:rename(TmpFile,File), + ok; _ -> exit(open_index_file) end. |