summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon MacMullen <simon@lshift.net>2008-11-26 13:03:29 +0000
committerSimon MacMullen <simon@lshift.net>2008-11-26 13:03:29 +0000
commitb8911dda1825fb91f536ca73522aa2fdebc9cae6 (patch)
tree80cd1a082a6f639a01fe26eba60a41ef9368ae69 /src
parent5b8ce05ddaac8984c8df1733dd72b7033b7d022a (diff)
downloadrabbitmq-server-git-b8911dda1825fb91f536ca73522aa2fdebc9cae6.tar.gz
Remove the 1M buffer.
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_linux_memory.erl13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/rabbit_linux_memory.erl b/src/rabbit_linux_memory.erl
index 19df932389..4220b0c9ab 100644
--- a/src/rabbit_linux_memory.erl
+++ b/src/rabbit_linux_memory.erl
@@ -77,13 +77,22 @@ handle_info(_Info, State) ->
end,
{noreply, State#state{alarmed = NewAlarmed}, ?MEMORY_CHECK_INTERVAL}.
+-define(BUFFER_SIZE, 1024).
+
%% file:read_file does not work on files in /proc as it seems to get the size
%% of the file first and then read that many bytes. But files in /proc always
%% have length 0, we just have to read until we get eof.
read_proc_file(File) ->
{ok, IoDevice} = file:open(File, [read, raw]),
- {ok, Res} = file:read(IoDevice, 1000000),
- Res.
+ read_proc_file(IoDevice, []).
+
+read_proc_file(IoDevice, Acc) ->
+ case file:read(IoDevice, ?BUFFER_SIZE) of
+ {ok, Res} ->
+ read_proc_file(IoDevice, Acc ++ Res);
+ eof ->
+ Acc
+ end.
%% A line looks like "FooBar: 123456 kB"
parse_line(Line) ->