瀏覽代碼

Add inode check to write_should_check

pull/509/head
Luke Bakken 5 年之前
父節點
當前提交
62e847acaa
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: D99DE30E43EAE440
共有 1 個檔案被更改,包括 6 行新增3 行删除
  1. +6
    -3
      src/lager_file_backend.erl

+ 6
- 3
src/lager_file_backend.erl 查看文件

@ -280,15 +280,18 @@ write(#state{name=Name, fd=FD,
write_should_check(#state{fd=undefined}, _Timestamp) -> write_should_check(#state{fd=undefined}, _Timestamp) ->
true; true;
write_should_check(#state{last_check=LastCheck0, check_interval=CheckInterval, write_should_check(#state{last_check=LastCheck0, check_interval=CheckInterval,
name=Name, ctime=Ctime0}, Timestamp) ->
name=Name, inode=Inode0, ctime=Ctime0}, Timestamp) ->
LastCheck1 = timer:now_diff(Timestamp, LastCheck0) div 1000, LastCheck1 = timer:now_diff(Timestamp, LastCheck0) div 1000,
case LastCheck1 >= CheckInterval of case LastCheck1 >= CheckInterval of
true -> true ->
true; true;
_ -> _ ->
% TODO this code is duplicated in the default rotator, but we need
% to know if the file has changed "out from under lager" so we don't
% write to an invalid FD
case file:read_file_info(Name, [raw]) of case file:read_file_info(Name, [raw]) of
{ok, #file_info{ctime=Ctime1}} ->
Ctime0 =/= Ctime1;
{ok, #file_info{inode=Inode1, ctime=Ctime1}} ->
Inode0 =/= Inode1 orelse Ctime0 =/= Ctime1;
_ -> _ ->
true true
end end

Loading…
取消
儲存