aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src/disk_log.erl
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2012-03-20 12:47:42 +0100
committerHans Bolinder <[email protected]>2012-03-20 12:52:31 +0100
commit51620fc966fc7c5b9427127f8221bf50c8435fd9 (patch)
tree582c1722fe6873c872622809da97c3140f2d3e7e /lib/kernel/src/disk_log.erl
parent75c1050ae68d6914cf9be4f7e7267c0c4b12f157 (diff)
downloadotp-51620fc966fc7c5b9427127f8221bf50c8435fd9.tar.gz
otp-51620fc966fc7c5b9427127f8221bf50c8435fd9.tar.bz2
otp-51620fc966fc7c5b9427127f8221bf50c8435fd9.zip
Make sure disk_log does not write too much data
While disk_log eagerly collects logged data for better performance, collecting too much data may choke the system and cause huge binaries to be written. The problem was addressed in OTP-9764, but the situation was not improved in all cases. Thanks to Richard Carlsson.
Diffstat (limited to 'lib/kernel/src/disk_log.erl')
-rw-r--r--lib/kernel/src/disk_log.erl10
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/kernel/src/disk_log.erl b/lib/kernel/src/disk_log.erl
index fb9415d440..f5f972c112 100644
--- a/lib/kernel/src/disk_log.erl
+++ b/lib/kernel/src/disk_log.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2012. 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
@@ -1034,10 +1034,9 @@ sync_loop(From, S) ->
-define(MAX_LOOK_AHEAD, 64*1024).
%% Inlined.
-log_loop(S, Pids, _Bins, _Sync, _Sz) when S#state.cache_error =/= ok ->
+log_loop(#state{cache_error = CE}=S, Pids, _Bins, _Sync, _Sz) when CE =/= ok ->
loop(cache_error(S, Pids));
-log_loop(#state{messages = []}=S, Pids, Bins, Sync, Sz)
- when Sz > ?MAX_LOOK_AHEAD ->
+log_loop(#state{}=S, Pids, Bins, Sync, Sz) when Sz > ?MAX_LOOK_AHEAD ->
loop(log_end(S, Pids, Bins, Sync));
log_loop(#state{messages = []}=S, Pids, Bins, Sync, Sz) ->
receive
@@ -1046,8 +1045,7 @@ log_loop(#state{messages = []}=S, Pids, Bins, Sync, Sz) ->
after 0 ->
loop(log_end(S, Pids, Bins, Sync))
end;
-log_loop(S, Pids, Bins, Sync, Sz) ->
- [M | Ms] = S#state.messages,
+log_loop(#state{messages = [M | Ms]}=S, Pids, Bins, Sync, Sz) ->
S1 = S#state{messages = Ms},
log_loop(M, Pids, Bins, Sync, Sz, S1, get(log)).