diff options
author | Simon MacMullen <simon@lshift.net> | 2008-11-26 13:03:29 +0000 |
---|---|---|
committer | Simon MacMullen <simon@lshift.net> | 2008-11-26 13:03:29 +0000 |
commit | 92e790bc5bb3ab2ad081c7e3a9933d320aff7d2d (patch) | |
tree | 80cd1a082a6f639a01fe26eba60a41ef9368ae69 | |
parent | 4070b743bc5f0ce01c4dd6922a44dee90b822778 (diff) | |
download | rabbitmq-server-92e790bc5bb3ab2ad081c7e3a9933d320aff7d2d.tar.gz |
Remove the 1M buffer.
-rw-r--r-- | src/rabbit_linux_memory.erl | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/rabbit_linux_memory.erl b/src/rabbit_linux_memory.erl index 19df9323..4220b0c9 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) -> |