summaryrefslogtreecommitdiff
path: root/src/connectionhandler.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2020-06-26 21:46:42 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2020-06-26 21:46:42 +0200
commit7198cd81e1db3c92f99a7079e7820a6cdc51c40a (patch)
tree4621907a1354698bc323ded206de9eddd2cab889 /src/connectionhandler.cc
parented9d39d488508894603bca2f134f5c4e5e7c3f80 (diff)
Do not do anything when unsubscribing an id that isn't in the subscription list.
Diffstat (limited to 'src/connectionhandler.cc')
-rw-r--r--src/connectionhandler.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/connectionhandler.cc b/src/connectionhandler.cc
index 26cce46..8b48c03 100644
--- a/src/connectionhandler.cc
+++ b/src/connectionhandler.cc
@@ -80,9 +80,16 @@ void ConnectionHandler::subscribe(clientid_t clientid, nodeid_t nodeid)
DEBUG(conn, "Added subscriber of %d\n", (int)nodeid);
}
-void ConnectionHandler::unsubscribe(clientid_t clientid, nodeid_t nodeid)
+bool ConnectionHandler::unsubscribe(clientid_t clientid, nodeid_t nodeid)
{
+ if(connlist[clientid].find(nodeid) == connlist[clientid].end())
+ {
+ // Trying to unsubscribe from a node that is not subscribed.
+ return false;
+ }
+
connlist[clientid].erase(nodeid);
+ return true;
}
SubscriberList ConnectionHandler::subscriberlist(NodeIdList nodes)