summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Klishin <michael@rabbitmq.com>2013-06-19 16:47:33 +0400
committerMichael Klishin <michael@rabbitmq.com>2013-06-19 16:47:33 +0400
commitc51b1af576e759b11cf6a3f527397e8434f65aab (patch)
tree0c2b3cb0d398af5113f678252e49febfaac1a11e
parent6ae3c5917807effb509ddaf72abf201a16f27b67 (diff)
downloadrabbitmq-server-c51b1af576e759b11cf6a3f527397e8434f65aab.tar.gz
Make sure set_alarm is idempotent
By making sure alarms list is unique.
-rw-r--r--src/rabbit_alarm.erl3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/rabbit_alarm.erl b/src/rabbit_alarm.erl
index 07247573..93997a37 100644
--- a/src/rabbit_alarm.erl
+++ b/src/rabbit_alarm.erl
@@ -104,7 +104,8 @@ handle_call(_Request, State) ->
{ok, not_understood, State}.
handle_event({set_alarm, Alarm}, State = #alarms{alarms = Alarms}) ->
- handle_set_alarm(Alarm, State#alarms{alarms = [Alarm|Alarms]});
+ UpdatedAlarms = lists:usort([Alarm|Alarms]),
+ handle_set_alarm(Alarm, State#alarms{alarms = UpdatedAlarms});
handle_event({clear_alarm, Alarm}, State = #alarms{alarms = Alarms}) ->
handle_clear_alarm(Alarm, State#alarms{alarms = lists:keydelete(Alarm, 1,