Update some comments for concise and sound description

This commit is contained in:
UENISHI Kota 2015-10-29 12:07:23 +09:00
parent 170b3cd797
commit 028135d927
2 changed files with 7 additions and 3 deletions

View file

@ -600,8 +600,6 @@ do_trim_chunk2(File, Offset, Size, Depth, STime, TO,
Proxy = orddict:fetch(HeadFLU, PD),
case ?FLU_PC:trim_chunk(Proxy, EpochID, File, Offset, Size, ?TIMEOUT) of
ok ->
%% From this point onward, we use the same code & logic path as
%% append does.
do_trim_midtail(RestFLUs, undefined, File, Offset, Size,
[HeadFLU], 0, STime, TO, S);
{error, trimmed} ->

View file

@ -1,6 +1,6 @@
-module(machi_plist).
%%% @doc persistent list of binaries that support mutual exclusion
%%% @doc persistent list of binaries
-export([open/2, close/1, find/2, add/2]).
@ -19,6 +19,9 @@
-spec open(file:filename_all(), proplists:proplist()) ->
{ok, plist()} | {error, file:posix()}.
open(Filename, _Opt) ->
%% TODO: This decode could fail if the file didn't finish writing
%% whole contents, which should be fixed by some persistent
%% solution.
List = case file:read_file(Filename) of
{ok, <<>>} -> [];
{ok, Bin} -> binary_to_term(Bin);
@ -48,6 +51,9 @@ add(Plist = #machi_plist{list=List0, fd=Fd}, Name) ->
{ok, Plist};
false ->
List = lists:append(List0, [Name]),
%% TODO: partial write could break the file with other
%% persistent info (even lose data of trimmed states);
%% needs a solution.
case file:pwrite(Fd, 0, term_to_binary(List)) of
ok ->
{ok, Plist#machi_plist{list=List}};