BIND 10 trac2932, updated. 612d8e5a1a35b9e359d610654c86b9b6fd1246cc [2932] Subscribe and unsubscribe notifications
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Sep 5 13:39:49 UTC 2013
The branch, trac2932 has been updated
via 612d8e5a1a35b9e359d610654c86b9b6fd1246cc (commit)
from 617c1d7c950beb8ddceb2ab03f37dca55959deb6 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 612d8e5a1a35b9e359d610654c86b9b6fd1246cc
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Thu Sep 5 15:39:09 2013 +0200
[2932] Subscribe and unsubscribe notifications
Doesn't actually use this for anything yet.
-----------------------------------------------------------------------
Summary of changes:
src/lib/config/ccsession.cc | 37 +++++++++++++++++++++++++++++++++++++
src/lib/config/ccsession.h | 2 ++
2 files changed, 39 insertions(+)
-----------------------------------------------------------------------
diff --git a/src/lib/config/ccsession.cc b/src/lib/config/ccsession.cc
index 780fe95..13d750c 100644
--- a/src/lib/config/ccsession.cc
+++ b/src/lib/config/ccsession.cc
@@ -902,5 +902,42 @@ ModuleCCSession::notify(const std::string& group, const std::string& name,
isc::cc::CC_TO_WILDCARD, false);
}
+ModuleCCSession::NotificationID
+ModuleCCSession::subscribeNotification(const std::string& notification_group,
+ const NotificationCallback& callback)
+{
+ // Either insert a new empty list of callbacks or get an existing one.
+ // Either way, get the iterator for its position.
+ const std::pair<SubscribedNotifications::iterator, bool>& inserted =
+ notifications_.insert(
+ std::pair<std::string, NotificationCallbacks>(notification_group,
+ NotificationCallbacks()));
+ if (inserted.second) {
+ // It was newly inserted. In that case, we need to subscribe to the
+ // group.
+ session_.subscribe(isc::cc::CC_GROUP_NOTIFICATION_PREFIX +
+ notification_group);
+ }
+ // Insert the callback to the chain
+ NotificationCallbacks& callbacks = inserted.first->second;
+ const NotificationCallbacks::iterator& callback_id =
+ callbacks.insert(callbacks.end(), callback);
+ // Just pack the iterators to form the ID
+ return (NotificationID(inserted.first, callback_id));
+}
+
+void
+ModuleCCSession::unsubscribeNotification(const NotificationID& notification) {
+ NotificationCallbacks& callbacks = notification.first->second;
+ // Remove the callback
+ callbacks.erase(notification.second);
+ // If it became empty, remove it from the map and unsubscribe
+ if (callbacks.empty()) {
+ session_.unsubscribe(isc::cc::CC_GROUP_NOTIFICATION_PREFIX +
+ notification.first->first);
+ notifications_.erase(notification.first);
+ }
+}
+
}
}
diff --git a/src/lib/config/ccsession.h b/src/lib/config/ccsession.h
index 49b49ea..066d900 100644
--- a/src/lib/config/ccsession.h
+++ b/src/lib/config/ccsession.h
@@ -656,6 +656,8 @@ private:
isc::cc::AbstractSession& session_;
ModuleSpec module_specification_;
AsyncRecvRequests async_recv_requests_;
+ SubscribedNotifications notifications_;
+
isc::data::ConstElementPtr handleConfigUpdate(
isc::data::ConstElementPtr new_config);
More information about the bind10-changes
mailing list