summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Lebedeff <alebedev@mirantis.com>2015-11-19 16:32:23 +0300
committerAlexey Lebedeff <alebedev@mirantis.com>2015-11-19 16:58:38 +0300
commit9673dbf0c4463aafc017d888eecad0e441cbdbc4 (patch)
tree732b22450577a3c3d6c1f54e34de84c61937b23c
parent4d0c3303154deb552b1a490b112b5588c85d5c18 (diff)
downloadrabbitmq-server-git-9673dbf0c4463aafc017d888eecad0e441cbdbc4.tar.gz
Make pmon:demonitor/2 respect its contract
Spec states that demonitor/2 should always return #state{}, but it wasn't the case when pid wasn't found in #state.dict. This made API unsafe to use, as it could lead to some other process storing incorrect data as a pmon state.
-rw-r--r--src/pmon.erl2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/pmon.erl b/src/pmon.erl
index f42530022a..cdfdc1c0c0 100644
--- a/src/pmon.erl
+++ b/src/pmon.erl
@@ -84,7 +84,7 @@ demonitor(Item, S = #state{dict = M, module = Module}) ->
case dict:find(Item, M) of
{ok, MRef} -> Module:demonitor(MRef),
S#state{dict = dict:erase(Item, M)};
- error -> M
+ error -> S
end.
is_monitored(Item, #state{dict = M}) -> dict:is_key(Item, M).