summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2014-06-13 11:39:43 +0100
committerSimon MacMullen <simon@rabbitmq.com>2014-06-13 11:39:43 +0100
commit2346839209d2c62fb9697282c2229c93fd70c77b (patch)
tree93c5fe348f6bcbc3eb842f05ecab5e76f02c8510
parent957b02f40a116e919c8d08f3dad8ac501f59a82d (diff)
downloadrabbitmq-server-bug26241.tar.gz
Ensure the limit field is always a number so we can't miss the need to interpret it. Yes, this means we won't update mem_relative if the size of the machine's physical memory changes at run time. I can live with that.bug26241
-rw-r--r--src/rabbit_disk_monitor.erl20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/rabbit_disk_monitor.erl b/src/rabbit_disk_monitor.erl
index fbf13a90..031a04f0 100644
--- a/src/rabbit_disk_monitor.erl
+++ b/src/rabbit_disk_monitor.erl
@@ -107,8 +107,8 @@ init([Limit]) ->
{stop, unsupported_platform}
end.
-handle_call(get_disk_free_limit, _From, State) ->
- {reply, interpret_limit(State#state.limit), State};
+handle_call(get_disk_free_limit, _From, State = #state{limit = Limit}) ->
+ {reply, Limit, State};
handle_call({set_disk_free_limit, Limit}, _From, State) ->
{reply, ok, set_disk_limits(State, Limit)};
@@ -153,29 +153,29 @@ code_change(_OldVsn, State, _Extra) ->
% the partition / drive containing this directory will be monitored
dir() -> rabbit_mnesia:dir().
-set_disk_limits(State, Limit) ->
+set_disk_limits(State, Limit0) ->
+ Limit = interpret_limit(Limit0),
State1 = State#state { limit = Limit },
rabbit_log:info("Disk free limit set to ~pMB~n",
- [trunc(interpret_limit(Limit) / 1000000)]),
+ [trunc(Limit / 1000000)]),
internal_update(State1).
internal_update(State = #state { limit = Limit,
dir = Dir,
alarmed = Alarmed}) ->
- CurrentFreeBytes = get_disk_free(Dir),
- LimitBytes = interpret_limit(Limit),
- NewAlarmed = CurrentFreeBytes < LimitBytes,
+ CurrentFree = get_disk_free(Dir),
+ NewAlarmed = CurrentFree < Limit,
case {Alarmed, NewAlarmed} of
{false, true} ->
- emit_update_info("insufficient", CurrentFreeBytes, LimitBytes),
+ emit_update_info("insufficient", CurrentFree, Limit),
rabbit_alarm:set_alarm({{resource_limit, disk, node()}, []});
{true, false} ->
- emit_update_info("sufficient", CurrentFreeBytes, LimitBytes),
+ emit_update_info("sufficient", CurrentFree, Limit),
rabbit_alarm:clear_alarm({resource_limit, disk, node()});
_ ->
ok
end,
- State #state {alarmed = NewAlarmed, actual = CurrentFreeBytes}.
+ State #state {alarmed = NewAlarmed, actual = CurrentFree}.
get_disk_free(Dir) ->
get_disk_free(Dir, os:type()).