瀏覽代碼

Don't flush notify msgs from msg queue

pull/427/head
Ulf Wiger 7 年之前
父節點
當前提交
8288adae5e
共有 1 個文件被更改,包括 1 次插入23 次删除
  1. +1
    -23
      src/lager_util.erl

+ 1
- 23
src/lager_util.erl 查看文件

@ -556,41 +556,19 @@ check_hwm(Shaper = #lager_shaper{lasttime = Last, dropped = Drop}) ->
case Last of case Last of
{M, S, N} -> {M, S, N} ->
%% still in same second, but have exceeded the high water mark %% still in same second, but have exceeded the high water mark
NewDrops = discard_messages(Now, Shaper#lager_shaper.filter, 0),
Timer = case erlang:read_timer(Shaper#lager_shaper.timer) of Timer = case erlang:read_timer(Shaper#lager_shaper.timer) of
false -> false ->
erlang:send_after(trunc((1000000 - N)/1000), self(), {shaper_expired, Shaper#lager_shaper.id}); erlang:send_after(trunc((1000000 - N)/1000), self(), {shaper_expired, Shaper#lager_shaper.id});
_ -> _ ->
Shaper#lager_shaper.timer Shaper#lager_shaper.timer
end, end,
{false, 0, Shaper#lager_shaper{dropped=Drop+NewDrops, timer=Timer}};
{false, 0, Shaper#lager_shaper{dropped=Drop+1, timer=Timer}};
_ -> _ ->
erlang:cancel_timer(Shaper#lager_shaper.timer), erlang:cancel_timer(Shaper#lager_shaper.timer),
%% different second, reset all counters and allow it %% different second, reset all counters and allow it
{true, Drop, Shaper#lager_shaper{dropped = 0, mps=1, lasttime = Now}} {true, Drop, Shaper#lager_shaper{dropped = 0, mps=1, lasttime = Now}}
end. end.
discard_messages(Second, Filter, Count) ->
{M, S, _} = os:timestamp(),
case Second of
{M, S, _} ->
receive
%% we only discard gen_event notifications, because
%% otherwise we might discard gen_event internal
%% messages, such as trapped EXITs
{notify, Event} ->
NewCount = case Filter(Event) of
false -> Count+1;
true -> Count
end,
discard_messages(Second, Filter, NewCount)
after 0 ->
Count
end;
_ ->
Count
end.
%% @private Build an atom for the gen_event process based on a sink name. %% @private Build an atom for the gen_event process based on a sink name.
%% For historical reasons, the default gen_event process for lager itself is named %% For historical reasons, the default gen_event process for lager itself is named
%% `lager_event'. For all other sinks, it is SinkName++`_lager_event' %% `lager_event'. For all other sinks, it is SinkName++`_lager_event'

Loading…
取消
儲存