From 9d7bd1274b7ff4578e108c8c13bad81cc2867d14 Mon Sep 17 00:00:00 2001 From: Michal 'vorner' Vaner Date: Mon, 20 May 2013 16:58:40 +0200 Subject: [2937] Interface of the notify method --- src/lib/config/ccsession.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/lib/config') diff --git a/src/lib/config/ccsession.h b/src/lib/config/ccsession.h index 995a5cd68b..aee6518c5f 100644 --- a/src/lib/config/ccsession.h +++ b/src/lib/config/ccsession.h @@ -425,6 +425,23 @@ public: params = isc::data::ConstElementPtr()); + /// \brief Send a notification to subscribed clients + /// + /// Send a notification message to all clients subscribed to the given + /// notification group. + /// + /// \param notification_group This parameter (indirectly) signifies what + /// clients should receive the notification. Only the clients that + /// subscribed to notifications on the same group receive it. + /// \param name The name of the event to notify about (for example + /// `config_changed`). + /// \param params Other parameters that describe the event. This might + /// be, for example, the new configuration value. + void notify(const std::string& notification_group, + const std::string& name, + const isc::data::ConstElementPtr& params = + isc::data::ConstElementPtr()); + /// \brief Convenience version of rpcCall /// /// This is exactly the same as the previous version of rpcCall, except -- cgit v1.2.3 From f3cd2b49392a4883751e2dbce2d8677e46d1f167 Mon Sep 17 00:00:00 2001 From: Michal 'vorner' Vaner Date: Tue, 21 May 2013 15:58:03 +0200 Subject: [2930] Sending notifications, C++ version --- src/lib/cc/proto_defs.cc | 2 ++ src/lib/config/ccsession.cc | 16 ++++++++++++++++ src/lib/config/tests/ccsession_unittests.cc | 22 ++++++++++++++++++++++ 3 files changed, 40 insertions(+) (limited to 'src/lib/config') diff --git a/src/lib/cc/proto_defs.cc b/src/lib/cc/proto_defs.cc index 8f7fb91d9d..9ecaf7a767 100644 --- a/src/lib/cc/proto_defs.cc +++ b/src/lib/cc/proto_defs.cc @@ -43,6 +43,8 @@ const char* const CC_COMMAND_STOP = "stop"; // The wildcards of some headers const char* const CC_TO_WILDCARD = "*"; const char* const CC_INSTANCE_WILDCARD = "*"; +// Prefixes for groups +const char* const CC_GROUP_NOTIFICATION_PREFIX = "notifications/"; // Reply codes const int CC_REPLY_NO_RECPT = -1; const int CC_REPLY_SUCCESS = 0; diff --git a/src/lib/config/ccsession.cc b/src/lib/config/ccsession.cc index d094ab9bf6..85c9a01389 100644 --- a/src/lib/config/ccsession.cc +++ b/src/lib/config/ccsession.cc @@ -884,5 +884,21 @@ ModuleCCSession::rpcCall(const std::string &command, const std::string &group, } } +void +ModuleCCSession::notify(const std::string &group, const std::string &name, + const ConstElementPtr ¶ms) +{ + const ElementPtr message(Element::createMap()); + const ElementPtr notification(Element::createList()); + notification->add(Element::create(name)); + if (params) { + notification->add(params); + } + message->set("notification", notification); + groupSendMsg(message, isc::cc::CC_GROUP_NOTIFICATION_PREFIX + group, + isc::cc::CC_INSTANCE_WILDCARD, + isc::cc::CC_TO_WILDCARD, false); +} + } } diff --git a/src/lib/config/tests/ccsession_unittests.cc b/src/lib/config/tests/ccsession_unittests.cc index c11cd24163..ffc5434977 100644 --- a/src/lib/config/tests/ccsession_unittests.cc +++ b/src/lib/config/tests/ccsession_unittests.cc @@ -117,6 +117,28 @@ TEST_F(CCSessionTest, rpcNoRecpt) { RPCRecipientMissing); } +// Test sending a notification +TEST_F(CCSessionTest, notify) { + ModuleCCSession mccs(ccspecfile("spec1.spec"), session, NULL, NULL, false, + false); + mccs.notify("group", "event", el("{\"param\": true}")); + const ConstElementPtr notification(el( + "[" + " \"notifications/group\"," + " \"*\"," + " {" + " \"notification\": [" + " \"event\", {" + " \"param\": true" + " }" + " ]" + " }," + " -1" + "]")); + EXPECT_TRUE(notification->equals(*session.getMsgQueue()->get(1))) << + session.getMsgQueue()->get(1)->toWire(); +} + TEST_F(CCSessionTest, createAnswer) { ConstElementPtr answer; answer = createAnswer(); -- cgit v1.2.3 From 88fe64ea760b7c2f4e2f5d4fdcc8c298481b46b7 Mon Sep 17 00:00:00 2001 From: Michal 'vorner' Vaner Date: Tue, 21 May 2013 16:38:18 +0200 Subject: [2930] Use a constant --- src/lib/cc/proto_defs.cc | 1 + src/lib/config/ccsession.cc | 2 +- src/lib/python/isc/config/ccsession.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src/lib/config') diff --git a/src/lib/cc/proto_defs.cc b/src/lib/cc/proto_defs.cc index 9ecaf7a767..2806c2a475 100644 --- a/src/lib/cc/proto_defs.cc +++ b/src/lib/cc/proto_defs.cc @@ -52,6 +52,7 @@ const int CC_REPLY_SUCCESS = 0; const char *const CC_PAYLOAD_LNAME = "lname"; const char *const CC_PAYLOAD_RESULT = "result"; const char *const CC_PAYLOAD_COMMAND = "command"; +const char *const CC_PAYLOAD_NOTIFICATION = "notification"; } } diff --git a/src/lib/config/ccsession.cc b/src/lib/config/ccsession.cc index 85c9a01389..a87be2b7b6 100644 --- a/src/lib/config/ccsession.cc +++ b/src/lib/config/ccsession.cc @@ -894,7 +894,7 @@ ModuleCCSession::notify(const std::string &group, const std::string &name, if (params) { notification->add(params); } - message->set("notification", notification); + message->set(isc::cc::CC_PAYLOAD_NOTIFICATION, notification); groupSendMsg(message, isc::cc::CC_GROUP_NOTIFICATION_PREFIX + group, isc::cc::CC_INSTANCE_WILDCARD, isc::cc::CC_TO_WILDCARD, false); diff --git a/src/lib/python/isc/config/ccsession.py b/src/lib/python/isc/config/ccsession.py index 8b824b8370..f0e852a943 100644 --- a/src/lib/python/isc/config/ccsession.py +++ b/src/lib/python/isc/config/ccsession.py @@ -554,7 +554,7 @@ class ModuleCCSession(ConfigData): notification = [event_name] if params is not None: notification.append(params) - self._session.group_sendmsg({'notification': notification}, + self._session.group_sendmsg({CC_PAYLOAD_NOTIFICATION: notification}, CC_GROUP_NOTIFICATION_PREFIX + notification_group, instance=CC_INSTANCE_WILDCARD, -- cgit v1.2.3 From c738282e2dabd4004dd451edc1d5dd36b4e59df7 Mon Sep 17 00:00:00 2001 From: JINMEI Tatuya Date: Tue, 21 May 2013 15:45:17 -0700 Subject: [2930] style fix: postion of & --- src/lib/config/ccsession.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/lib/config') diff --git a/src/lib/config/ccsession.cc b/src/lib/config/ccsession.cc index a87be2b7b6..0d43b2727c 100644 --- a/src/lib/config/ccsession.cc +++ b/src/lib/config/ccsession.cc @@ -885,8 +885,8 @@ ModuleCCSession::rpcCall(const std::string &command, const std::string &group, } void -ModuleCCSession::notify(const std::string &group, const std::string &name, - const ConstElementPtr ¶ms) +ModuleCCSession::notify(const std::string& group, const std::string& name, + const ConstElementPtr& params) { const ElementPtr message(Element::createMap()); const ElementPtr notification(Element::createList()); -- cgit v1.2.3 From e7591db5df9c7694e1e0e3f7dd3e2d77753999c1 Mon Sep 17 00:00:00 2001 From: Michal 'vorner' Vaner Date: Wed, 22 May 2013 11:17:48 +0200 Subject: [2930] Doxygen update Clarify few points in the method's doxygen comment. --- src/lib/config/ccsession.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/lib/config') diff --git a/src/lib/config/ccsession.h b/src/lib/config/ccsession.h index aee6518c5f..fd93545acc 100644 --- a/src/lib/config/ccsession.h +++ b/src/lib/config/ccsession.h @@ -430,13 +430,20 @@ public: /// Send a notification message to all clients subscribed to the given /// notification group. /// + /// This method does not not block. + /// + /// See docs/design/ipc-high.txt for details about notifications and + /// the format of messages sent. + /// + /// \throw CCSessionError for low-level communication errors. /// \param notification_group This parameter (indirectly) signifies what /// clients should receive the notification. Only the clients that /// subscribed to notifications on the same group receive it. /// \param name The name of the event to notify about (for example /// `config_changed`). /// \param params Other parameters that describe the event. This might - /// be, for example, the new configuration value. + /// be, for example, the new configuration value. This can be any + /// data element, but it is common for it to be map. void notify(const std::string& notification_group, const std::string& name, const isc::data::ConstElementPtr& params = -- cgit v1.2.3 From 2ae9ac7bb5a19741eb21b0ccec951588c5672d1d Mon Sep 17 00:00:00 2001 From: Michal 'vorner' Vaner Date: Wed, 22 May 2013 11:22:07 +0200 Subject: [2930] Add test for missing parameters --- src/lib/config/tests/ccsession_unittests.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/lib/config') diff --git a/src/lib/config/tests/ccsession_unittests.cc b/src/lib/config/tests/ccsession_unittests.cc index ffc5434977..700ffe4d36 100644 --- a/src/lib/config/tests/ccsession_unittests.cc +++ b/src/lib/config/tests/ccsession_unittests.cc @@ -139,6 +139,24 @@ TEST_F(CCSessionTest, notify) { session.getMsgQueue()->get(1)->toWire(); } +// Test sending a notification +TEST_F(CCSessionTest, notifyNoParams) { + ModuleCCSession mccs(ccspecfile("spec1.spec"), session, NULL, NULL, false, + false); + mccs.notify("group", "event"); + const ConstElementPtr notification(el( + "[" + " \"notifications/group\"," + " \"*\"," + " {" + " \"notification\": [\"event\"]" + " }," + " -1" + "]")); + EXPECT_TRUE(notification->equals(*session.getMsgQueue()->get(1))) << + session.getMsgQueue()->get(1)->toWire(); +} + TEST_F(CCSessionTest, createAnswer) { ConstElementPtr answer; answer = createAnswer(); -- cgit v1.2.3 From cd146974efff9794c989296158c0e05997da1edf Mon Sep 17 00:00:00 2001 From: Michal 'vorner' Vaner Date: Thu, 23 May 2013 10:39:52 +0200 Subject: [2930] Adjust terminology in docs So it is the same as in the ipc-high.txt. --- src/lib/config/ccsession.h | 6 +++--- src/lib/python/isc/config/ccsession.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/lib/config') diff --git a/src/lib/config/ccsession.h b/src/lib/config/ccsession.h index fd93545acc..cc4a93e9c8 100644 --- a/src/lib/config/ccsession.h +++ b/src/lib/config/ccsession.h @@ -425,9 +425,9 @@ public: params = isc::data::ConstElementPtr()); - /// \brief Send a notification to subscribed clients + /// \brief Send a notification to subscribed users /// - /// Send a notification message to all clients subscribed to the given + /// Send a notification message to all users subscribed to the given /// notification group. /// /// This method does not not block. @@ -437,7 +437,7 @@ public: /// /// \throw CCSessionError for low-level communication errors. /// \param notification_group This parameter (indirectly) signifies what - /// clients should receive the notification. Only the clients that + /// users should receive the notification. Only the users that /// subscribed to notifications on the same group receive it. /// \param name The name of the event to notify about (for example /// `config_changed`). diff --git a/src/lib/python/isc/config/ccsession.py b/src/lib/python/isc/config/ccsession.py index 7e01e8428a..6df93c0f30 100644 --- a/src/lib/python/isc/config/ccsession.py +++ b/src/lib/python/isc/config/ccsession.py @@ -541,9 +541,9 @@ class ModuleCCSession(ConfigData): def notify(self, notification_group, event_name, params=None): """ - Send a notification to subscribed clients. + Send a notification to subscribed users. - Send a notification message to all clients subscribed to the given + Send a notification message to all users subscribed to the given notification group. See docs/design/ipc-high.txt for details about notifications @@ -553,7 +553,7 @@ class ModuleCCSession(ConfigData): - CCSessionError: for low-level communication errors. Params: - notification_group (string): This parameter (indirectly) signifies - what clients should receive the notification. Only clients that + what users should receive the notification. Only users that subscribed to notifications on the same group receive it. - event_name (string): The name of the event to notify about (for example `config_changed`). -- cgit v1.2.3 From e8a9043a2508edd209a01facb71fe4bac4d9eceb Mon Sep 17 00:00:00 2001 From: Michal 'vorner' Vaner Date: Thu, 23 May 2013 10:47:45 +0200 Subject: [2930] Replace example for a more obvious one --- src/lib/config/ccsession.h | 7 ++++--- src/lib/python/isc/config/ccsession.py | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src/lib/config') diff --git a/src/lib/config/ccsession.h b/src/lib/config/ccsession.h index cc4a93e9c8..04e3046af6 100644 --- a/src/lib/config/ccsession.h +++ b/src/lib/config/ccsession.h @@ -440,10 +440,11 @@ public: /// users should receive the notification. Only the users that /// subscribed to notifications on the same group receive it. /// \param name The name of the event to notify about (for example - /// `config_changed`). + /// `new_group_member`). /// \param params Other parameters that describe the event. This might - /// be, for example, the new configuration value. This can be any - /// data element, but it is common for it to be map. + /// be, for example, the ID of the new member and the name of the + /// group. This can be any data element, but it is common for it to be + /// map. void notify(const std::string& notification_group, const std::string& name, const isc::data::ConstElementPtr& params = diff --git a/src/lib/python/isc/config/ccsession.py b/src/lib/python/isc/config/ccsession.py index 6df93c0f30..53e531d6ab 100644 --- a/src/lib/python/isc/config/ccsession.py +++ b/src/lib/python/isc/config/ccsession.py @@ -556,10 +556,11 @@ class ModuleCCSession(ConfigData): what users should receive the notification. Only users that subscribed to notifications on the same group receive it. - event_name (string): The name of the event to notify about (for - example `config_changed`). + example `new_group_member`). - params: Other parameters that describe the event. This might be, for - example, the new configuration value. This can be any data that can - be sent over the isc.cc.Session, but it is common for it to be dict. + example, the ID of the new member and the name of the group. This can + be any data that can be sent over the isc.cc.Session, but it is + common for it to be dict. Returns: Nothing """ notification = [event_name] -- cgit v1.2.3 From 007341505307a53b43802c747fe09435346bbf46 Mon Sep 17 00:00:00 2001 From: Michal 'vorner' Vaner Date: Mon, 17 Jun 2013 15:39:29 +0200 Subject: [2726] Pass plain old C string This should prevent cppcheck from complaining on several places about passing c_str() as string argument. It is not possible to remove the c_str() from the macro, as it might be needed at other places. Putting the suppression at several places seems wrong, so this is the least ugly solution. --- src/lib/config/config_data.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib/config') diff --git a/src/lib/config/config_data.h b/src/lib/config/config_data.h index e40600d728..bcc97de409 100644 --- a/src/lib/config/config_data.h +++ b/src/lib/config/config_data.h @@ -29,7 +29,7 @@ namespace config { /// point to anything defined in the .spec file) class DataNotFoundError : public isc::Exception { public: - DataNotFoundError(const char* file, size_t line, const std::string& what) : + DataNotFoundError(const char* file, size_t line, const char* what) : isc::Exception(file, line, what) {} }; -- cgit v1.2.3 From 87c3781cf964f63b044153a39b05518f72d8b80e Mon Sep 17 00:00:00 2001 From: Michal 'vorner' Vaner Date: Tue, 9 Jul 2013 14:48:11 +0200 Subject: [2862] Subscribe and unsubscribe on MCCS --- src/lib/config/ccsession.h | 14 ++++++++++++++ src/lib/config/tests/ccsession_unittests.cc | 11 +++++++++++ 2 files changed, 25 insertions(+) (limited to 'src/lib/config') diff --git a/src/lib/config/ccsession.h b/src/lib/config/ccsession.h index 04e3046af6..5c614e6aa7 100644 --- a/src/lib/config/ccsession.h +++ b/src/lib/config/ccsession.h @@ -575,6 +575,20 @@ public: /// \param id The id of request as returned by groupRecvMsgAsync. void cancelAsyncRecv(const AsyncRecvRequestID& id); + /// \brief Subscribe to a group + /// + /// Wrapper around the CCSession::subscribe. + void subscribe(const std::string& group) { + session_.subscribe(group, isc::cc::CC_INSTANCE_WILDCARD); + } + + /// \brief Unsubscribe from a group. + /// + /// Wrapper around the CCSession::unsubscribe. + void unsubscribe(const std::string& group) { + session_.unsubscribe(group, isc::cc::CC_INSTANCE_WILDCARD); + } + private: ModuleSpec readModuleSpecification(const std::string& filename); void startCheck(); diff --git a/src/lib/config/tests/ccsession_unittests.cc b/src/lib/config/tests/ccsession_unittests.cc index 700ffe4d36..d958529599 100644 --- a/src/lib/config/tests/ccsession_unittests.cc +++ b/src/lib/config/tests/ccsession_unittests.cc @@ -157,6 +157,17 @@ TEST_F(CCSessionTest, notifyNoParams) { session.getMsgQueue()->get(1)->toWire(); } +// Try to subscribe and unsubscribe once again +TEST_F(CCSessionTest, subscribe) { + ModuleCCSession mccs(ccspecfile("spec1.spec"), session, NULL, NULL, false, + false); + EXPECT_FALSE(session.haveSubscription("A group", "*")); + mccs.subscribe("A group"); + EXPECT_TRUE(session.haveSubscription("A group", "*")); + mccs.unsubscribe("A group"); + EXPECT_FALSE(session.haveSubscription("A group", "*")); +} + TEST_F(CCSessionTest, createAnswer) { ConstElementPtr answer; answer = createAnswer(); -- cgit v1.2.3 From 661dae35e38a4b4a7d3f22b785509ceb528003e1 Mon Sep 17 00:00:00 2001 From: Michal 'vorner' Vaner Date: Fri, 12 Jul 2013 11:05:29 +0200 Subject: [2862] Hack in a way to receive foreign commands Provide a callback to receive commands for foreign modules. The current implementation is somewhat broken and unsatisfactory, but let's leave that up for later. We need a way now. --- src/lib/config/ccsession.cc | 2 ++ src/lib/config/ccsession.h | 32 +++++++++++++++++++++++++++++ src/lib/config/tests/ccsession_unittests.cc | 26 +++++++++++++++++++++++ 3 files changed, 60 insertions(+) (limited to 'src/lib/config') diff --git a/src/lib/config/ccsession.cc b/src/lib/config/ccsession.cc index 0d43b2727c..780fe95a15 100644 --- a/src/lib/config/ccsession.cc +++ b/src/lib/config/ccsession.cc @@ -595,6 +595,8 @@ ModuleCCSession::checkModuleCommand(const std::string& cmd_str, "Command given but no " "command handler for module")); } + } else if (unhandled_callback_) { + unhandled_callback_(cmd_str, target_module, arg); } return (ElementPtr()); } diff --git a/src/lib/config/ccsession.h b/src/lib/config/ccsession.h index 5c614e6aa7..c536861ca1 100644 --- a/src/lib/config/ccsession.h +++ b/src/lib/config/ccsession.h @@ -589,6 +589,36 @@ public: session_.unsubscribe(group, isc::cc::CC_INSTANCE_WILDCARD); } + /// \brief Callback type for unhandled commands + /// + /// The type of functions that are not handled by the ModuleCCSession + /// because they are not aimed at the module. + /// + /// The parameters are: + /// - Name of the command. + /// - The module it was aimed for (may be empty). + /// - The parameters of the command. + typedef boost::function + UnhandledCallback; + + /// \brief Register a callback for messages sent to foreign modules. + /// + /// Usually, a command aimed at foreign module (or sent directly) + /// is discarded. By registering a callback here, these can be + /// examined. + /// + /// \note A callback overwrites the previous one set. + /// \todo This is a temporary, unclean, solution. A more generic + /// one needs to be designed. Also, a solution that is able + /// to send an answer would be great. + /// + /// \param callback The new callback to use. It may be an empty + /// function. + void setUnhandledCallback(const UnhandledCallback& callback) { + unhandled_callback_ = callback; + } + private: ModuleSpec readModuleSpecification(const std::string& filename); void startCheck(); @@ -638,6 +668,8 @@ private: isc::data::ConstElementPtr new_config); ModuleSpec fetchRemoteSpec(const std::string& module, bool is_filename); + + UnhandledCallback unhandled_callback_; }; /// \brief Default handler for logging config updates diff --git a/src/lib/config/tests/ccsession_unittests.cc b/src/lib/config/tests/ccsession_unittests.cc index d958529599..4a04412b43 100644 --- a/src/lib/config/tests/ccsession_unittests.cc +++ b/src/lib/config/tests/ccsession_unittests.cc @@ -697,6 +697,16 @@ TEST_F(CCSessionTest, remoteConfig) { } } +void +callback(std::string* command, std::string* target, ConstElementPtr *params, + const std::string& command_real, const std::string& target_real, + const ConstElementPtr& params_real) +{ + *command = command_real; + *target = target_real; + *params = params_real; +} + TEST_F(CCSessionTest, ignoreRemoteConfigCommands) { // client will ask for config session.getMessages()->add(createAnswer(0, el("{ }"))); @@ -732,6 +742,22 @@ TEST_F(CCSessionTest, ignoreRemoteConfigCommands) { result = mccs.checkCommand(); EXPECT_EQ(0, session.getMsgQueue()->size()); EXPECT_EQ(0, result); + + // Check that we can get the ignored commands by registering a callback + std::string command, target; + ConstElementPtr params; + mccs.setUnhandledCallback(boost::bind(&callback, &command, &target, + ¶ms, _1, _2, _3)); + session.addMessage(el("{ \"command\": [ \"good_command\"," + "{\"param\": true} ] }"), "Spec1", "*"); + EXPECT_EQ(1, session.getMsgQueue()->size()); + result = mccs.checkCommand(); + EXPECT_EQ(0, session.getMsgQueue()->size()); + EXPECT_EQ(0, result); + + EXPECT_EQ("good_command", command); + EXPECT_EQ("Spec1", target); + EXPECT_TRUE(params && el("{\"param\": true}")->equals(*params)); } TEST_F(CCSessionTest, initializationFail) { -- cgit v1.2.3 From ccb473862e3046f9cf0dcc923757a4ada7ba093f Mon Sep 17 00:00:00 2001 From: Michal 'vorner' Vaner Date: Thu, 5 Sep 2013 14:04:55 +0200 Subject: [2932] Interface to subscribe and unsubscribe notifications Not documented as of yet, and no implementation. --- src/lib/config/ccsession.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/lib/config') diff --git a/src/lib/config/ccsession.h b/src/lib/config/ccsession.h index c536861ca1..49b49ea7d8 100644 --- a/src/lib/config/ccsession.h +++ b/src/lib/config/ccsession.h @@ -575,6 +575,19 @@ public: /// \param id The id of request as returned by groupRecvMsgAsync. void cancelAsyncRecv(const AsyncRecvRequestID& id); + typedef boost::function + NotificationCallback; + typedef std::list NotificationCallbacks; + typedef std::map + SubscribedNotifications; + typedef std::pair + NotificationID; + NotificationID subscribeNotification(const std::string& notification_group, + const NotificationCallback& callback); + void unsubscribeNotification(const NotificationID& notification); + /// \brief Subscribe to a group /// /// Wrapper around the CCSession::subscribe. -- cgit v1.2.3 From 617c1d7c950beb8ddceb2ab03f37dca55959deb6 Mon Sep 17 00:00:00 2001 From: Michal 'vorner' Vaner Date: Thu, 5 Sep 2013 14:46:06 +0200 Subject: [2932] Tests for the notification reception in C++ --- src/lib/config/tests/ccsession_unittests.cc | 64 +++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'src/lib/config') diff --git a/src/lib/config/tests/ccsession_unittests.cc b/src/lib/config/tests/ccsession_unittests.cc index 4a04412b43..4d987d4590 100644 --- a/src/lib/config/tests/ccsession_unittests.cc +++ b/src/lib/config/tests/ccsession_unittests.cc @@ -87,6 +87,70 @@ protected: const std::string root_name; }; +void +notificationCallback(std::vector* called, + const std::string& id, const std::string& notification, + const ConstElementPtr& params) +{ + called->push_back(id); + EXPECT_EQ("event", notification); + EXPECT_TRUE(el("{\"param\": true}")->equals(*params)); +} + +TEST_F(CCSessionTest, receiveNotification) { + // Not subscribed to the group yet + ModuleCCSession mccs(ccspecfile("spec1.spec"), session, NULL, NULL, + false, false); + EXPECT_FALSE(session.haveSubscription("notifications/group", "*")); + std::vector called; + // Subscribe to the notification. Twice. + const ModuleCCSession::NotificationID& first = + mccs.subscribeNotification("group", boost::bind(¬ificationCallback, + &called, "first", + _1, _2)); + const ModuleCCSession::NotificationID& second = + mccs.subscribeNotification("group", boost::bind(¬ificationCallback, + &called, "second", + _1, _2)); + EXPECT_TRUE(session.haveSubscription("notifications/group", "*")); + EXPECT_TRUE(called.empty()); + // Send the notification + session.getMessages()->add(el("{" + " \"notification\": [" + " \"event\", {" + " \"param\": true" + " }" + " ]" + " }")); + mccs.checkCommand(); + ASSERT_EQ(2, called.size()); + EXPECT_EQ("first", called[0]); + EXPECT_EQ("second", called[1]); + called.clear(); + // Unsubscribe one of them + mccs.unsubscribeNotification(first); + // We are still subscribed to the group and handle the requests + EXPECT_TRUE(session.haveSubscription("notifications/group", "*")); + // Send the notification + session.getMessages()->add(el("{" + " \"notification\": [" + " \"event\", {" + " \"param\": true" + " }" + " ]" + " }")); + mccs.checkCommand(); + ASSERT_EQ(1, called.size()); + EXPECT_EQ("second", called[0]); + // Try to unsubscribe again. That should fail. + EXPECT_THROW(mccs.unsubscribeNotification(first), isc::InvalidParameter); + EXPECT_TRUE(session.haveSubscription("notifications/group", "*")); + // Unsubscribe the other one too. That should cancel the upstream + // subscription + mccs.unsubscribeNotification(second); + EXPECT_FALSE(session.haveSubscription("notifications/group", "*")); +} + // Test we can send an RPC (command) and get an answer. The answer is success // in this case. TEST_F(CCSessionTest, rpcCallSuccess) { -- cgit v1.2.3 From 612d8e5a1a35b9e359d610654c86b9b6fd1246cc Mon Sep 17 00:00:00 2001 From: Michal 'vorner' Vaner Date: Thu, 5 Sep 2013 15:39:09 +0200 Subject: [2932] Subscribe and unsubscribe notifications Doesn't actually use this for anything yet. --- src/lib/config/ccsession.cc | 37 +++++++++++++++++++++++++++++++++++++ src/lib/config/ccsession.h | 2 ++ 2 files changed, 39 insertions(+) (limited to 'src/lib/config') diff --git a/src/lib/config/ccsession.cc b/src/lib/config/ccsession.cc index 780fe95a15..13d750ccd7 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& inserted = + notifications_.insert( + std::pair(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 49b49ea7d8..066d900aba 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); -- cgit v1.2.3 From d5d77acc2f46862e365fb42ae983158bd47eee9b Mon Sep 17 00:00:00 2001 From: Michal 'vorner' Vaner Date: Fri, 6 Sep 2013 08:36:21 +0200 Subject: [2932] Handle the notifications Detect incoming notifications and handle them according to the subscriptions. --- src/lib/config/ccsession.cc | 47 +++++++++++++++++++++++++++++ src/lib/config/ccsession.h | 2 ++ src/lib/config/tests/ccsession_unittests.cc | 19 +++++------- 3 files changed, 56 insertions(+), 12 deletions(-) (limited to 'src/lib/config') diff --git a/src/lib/config/ccsession.cc b/src/lib/config/ccsession.cc index 13d750ccd7..c82a9350d3 100644 --- a/src/lib/config/ccsession.cc +++ b/src/lib/config/ccsession.cc @@ -611,6 +611,11 @@ ModuleCCSession::checkCommand() { return (0); } + // In case it is notification, eat it. + if (checkNotification(routing, data)) { + return (0); + } + /* ignore result messages (in case we're out of sync, to prevent * pingpongs */ if (data->getType() != Element::map || @@ -939,5 +944,47 @@ ModuleCCSession::unsubscribeNotification(const NotificationID& notification) { } } +bool +ModuleCCSession::checkNotification(const data::ConstElementPtr& envelope, + const data::ConstElementPtr& msg) +{ + if (msg->getType() != data::Element::map) { + // If it's not a map, then it's not a notification + return (false); + } + if (msg->contains(isc::cc::CC_PAYLOAD_NOTIFICATION)) { + // There's a notification inside. Extract its parameters. + const std::string& group = + envelope->get(isc::cc::CC_HEADER_GROUP)->stringValue(); + const std::string& notification_group = + group.substr(std::string(isc::cc::CC_GROUP_NOTIFICATION_PREFIX). + size()); + const data::ConstElementPtr& notification = + msg->get(isc::cc::CC_PAYLOAD_NOTIFICATION); + // The first one is the event that happened + const std::string& event = notification->get(0)->stringValue(); + // Any other params are second. But they may be missing + const data::ConstElementPtr params = + notification->size() == 1 ? data::ConstElementPtr() : + notification->get(1); + // Find the chain of notification callbacks + const SubscribedNotifications::iterator& chain_iter = + notifications_.find(notification_group); + if (chain_iter == notifications_.end()) { + // This means we no longer have any notifications for this group. + // This can happen legally as a race condition - if msgq sends + // us a notification, but we unsubscribe before we get to it + // in the input stream. + return (false); + } + BOOST_FOREACH(const NotificationCallback& callback, + chain_iter->second) { + callback(event, params); + } + return (true); + } + return (false); // Not a notification +} + } } diff --git a/src/lib/config/ccsession.h b/src/lib/config/ccsession.h index 066d900aba..5f17ff25ff 100644 --- a/src/lib/config/ccsession.h +++ b/src/lib/config/ccsession.h @@ -647,6 +647,8 @@ private: /// otherwise. bool checkAsyncRecv(const data::ConstElementPtr& envelope, const data::ConstElementPtr& msg); + bool checkNotification(const data::ConstElementPtr& envelope, + const data::ConstElementPtr& msg); /// \brief Checks if a message with this envelope matches the request bool requestMatch(const AsyncRecvRequest& request, const data::ConstElementPtr& envelope) const; diff --git a/src/lib/config/tests/ccsession_unittests.cc b/src/lib/config/tests/ccsession_unittests.cc index 4d987d4590..b9c70d03b7 100644 --- a/src/lib/config/tests/ccsession_unittests.cc +++ b/src/lib/config/tests/ccsession_unittests.cc @@ -115,13 +115,14 @@ TEST_F(CCSessionTest, receiveNotification) { EXPECT_TRUE(session.haveSubscription("notifications/group", "*")); EXPECT_TRUE(called.empty()); // Send the notification - session.getMessages()->add(el("{" + const isc::data::ConstElementPtr msg = el("{" " \"notification\": [" " \"event\", {" " \"param\": true" " }" " ]" - " }")); + " }"); + session.addMessage(msg, "notifications/group", "*"); mccs.checkCommand(); ASSERT_EQ(2, called.size()); EXPECT_EQ("first", called[0]); @@ -132,23 +133,17 @@ TEST_F(CCSessionTest, receiveNotification) { // We are still subscribed to the group and handle the requests EXPECT_TRUE(session.haveSubscription("notifications/group", "*")); // Send the notification - session.getMessages()->add(el("{" - " \"notification\": [" - " \"event\", {" - " \"param\": true" - " }" - " ]" - " }")); + session.addMessage(msg, "notifications/group", "*"); mccs.checkCommand(); ASSERT_EQ(1, called.size()); EXPECT_EQ("second", called[0]); - // Try to unsubscribe again. That should fail. - EXPECT_THROW(mccs.unsubscribeNotification(first), isc::InvalidParameter); - EXPECT_TRUE(session.haveSubscription("notifications/group", "*")); // Unsubscribe the other one too. That should cancel the upstream // subscription mccs.unsubscribeNotification(second); EXPECT_FALSE(session.haveSubscription("notifications/group", "*")); + // Nothing crashes if out of sync notification comes unexpected + session.addMessage(msg, "notifications/group", "*"); + EXPECT_NO_THROW(mccs.checkCommand()); } // Test we can send an RPC (command) and get an answer. The answer is success -- cgit v1.2.3 From 2093c5f82308d58537cb01130a2e54109cfbd6d7 Mon Sep 17 00:00:00 2001 From: Michal 'vorner' Vaner Date: Fri, 6 Sep 2013 08:51:15 +0200 Subject: [2932] Document the notification interface --- src/lib/config/ccsession.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/lib/config') diff --git a/src/lib/config/ccsession.h b/src/lib/config/ccsession.h index 5f17ff25ff..75c3ee6fff 100644 --- a/src/lib/config/ccsession.h +++ b/src/lib/config/ccsession.h @@ -575,17 +575,55 @@ public: /// \param id The id of request as returned by groupRecvMsgAsync. void cancelAsyncRecv(const AsyncRecvRequestID& id); + /// \brief Called when a notification comes + /// + /// The callback should be exception-free. If it raises an exception, + /// it'll leak through the event loop up and probably terminate the + /// application. + /// + /// \param event_name The identification of event type. + /// \param params The parameters of the event. This may be NULL + /// pointer in case no parameters were sent with the event. typedef boost::function NotificationCallback; + + /// \brief Multiple notification callbacks for the same notification typedef std::list NotificationCallbacks; + + /// \brief Mapping from groups to callbacks typedef std::map SubscribedNotifications; + + /// \brief Identification of single callback typedef std::pair NotificationID; + + /// \brief Subscribe to a notification group + /// + /// From now on, every notification that is sent to the given group + /// triggers the passed callback. + /// + /// There may be multiple (independent) callbacks for the same channel. + /// This one adds a new one, to the end of the chain (the callbacks + /// are called in the same order as they were registered). + /// + /// \param notification_group The channel of notifications. + /// \param callback The callback to be added. + /// \return ID of the notification callback. It is an opaque ID and can + /// be used to remove this callback. NotificationID subscribeNotification(const std::string& notification_group, const NotificationCallback& callback); + + /// \brief Unsubscribe the callback from its notification group. + /// + /// Express that the desire for this callback to be executed is no longer + /// relevant. All the other callbacks (even for the same notification + /// group) are left intact. + /// + /// \param notification The ID of notification callback returned by + /// subscribeNotification. void unsubscribeNotification(const NotificationID& notification); /// \brief Subscribe to a group -- cgit v1.2.3 From eaff454676513de3bf85d76c9ab724cf8191c649 Mon Sep 17 00:00:00 2001 From: Kean Johnston Date: Wed, 18 Sep 2013 13:34:31 +0200 Subject: [3170] fix rulkes that were breaking parallel builds --- src/bin/auth/Makefile.am | 12 +++++++++--- src/bin/d2/Makefile.am | 7 +++++-- src/bin/dhcp4/Makefile.am | 7 +++++-- src/bin/dhcp6/Makefile.am | 7 +++++-- src/bin/resolver/Makefile.am | 8 +++++--- src/lib/asiodns/Makefile.am | 7 +++++-- src/lib/cache/Makefile.am | 7 +++++-- src/lib/cc/Makefile.am | 7 +++++-- src/lib/config/Makefile.am | 7 +++++-- src/lib/datasrc/Makefile.am | 12 ++++++++++-- src/lib/datasrc/memory/Makefile.am | 7 +++++-- src/lib/dhcp_ddns/Makefile.am | 7 +++++-- src/lib/dhcpsrv/Makefile.am | 7 +++++-- src/lib/dns/Makefile.am | 8 ++++++-- src/lib/hooks/Makefile.am | 7 +++++-- src/lib/log/tests/Makefile.am | 7 +++++-- src/lib/nsas/Makefile.am | 7 +++++-- src/lib/resolve/Makefile.am | 7 +++++-- src/lib/server_common/Makefile.am | 7 +++++-- src/lib/util/tests/Makefile.am | 3 +-- src/lib/util/threads/tests/Makefile.am | 3 +-- 21 files changed, 107 insertions(+), 44 deletions(-) (limited to 'src/lib/config') diff --git a/src/bin/auth/Makefile.am b/src/bin/auth/Makefile.am index 1bb5ee96e8..5937ba0c03 100644 --- a/src/bin/auth/Makefile.am +++ b/src/bin/auth/Makefile.am @@ -20,7 +20,7 @@ CLEANFILES = *.gcno *.gcda auth.spec spec_config.h CLEANFILES += auth_messages.h auth_messages.cc CLEANFILES += gen-statisticsitems.py # auto-generated by gen-statisticsitems.py -CLEANFILES += statistics.cc statistics_items.h b10-auth.xml tests/statistics_unittest.cc +CLEANFILES += statistics.cc statistics_items.h b10-auth.xml tests/statistics_unittest.cc s-genstats s-messages man_MANS = b10-auth.8 DISTCLEANFILES = $(man_MANS) @@ -49,14 +49,20 @@ gen-statisticsitems.py: gen-statisticsitems.py.pre $(SED) -e "s|@@LOCALSTATEDIR@@|$(localstatedir)|" gen-statisticsitems.py.pre >$@ chmod +x $@ -auth.spec b10-auth.xml statistics_items.h statistics.cc tests/statistics_unittest.cc: Makefile gen-statisticsitems.py +auth.spec b10-auth.xml statistics_items.h statistics.cc tests/statistics_unittest.cc: Makefile s-genstats + +s-genstats: gen-statisticsitems.py ./gen-statisticsitems.py + touch $@ spec_config.h: spec_config.h.pre $(SED) -e "s|@@LOCALSTATEDIR@@|$(localstatedir)|" spec_config.h.pre >$@ -auth_messages.h auth_messages.cc: auth_messages.mes +auth_messages.h auth_messages.cc: s-messages + +s-messages: auth_messages.mes $(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/bin/auth/auth_messages.mes + touch $@ BUILT_SOURCES = spec_config.h auth_messages.h auth_messages.cc # auto-generated by gen-statisticsitems.py diff --git a/src/bin/d2/Makefile.am b/src/bin/d2/Makefile.am index f95ae9db46..85a3ca3a12 100644 --- a/src/bin/d2/Makefile.am +++ b/src/bin/d2/Makefile.am @@ -16,7 +16,7 @@ endif pkglibexecdir = $(libexecdir)/@PACKAGE@ -CLEANFILES = *.gcno *.gcda spec_config.h d2_messages.h d2_messages.cc +CLEANFILES = *.gcno *.gcda spec_config.h d2_messages.h d2_messages.cc s-messages man_MANS = b10-dhcp-ddns.8 DISTCLEANFILES = $(man_MANS) @@ -39,8 +39,11 @@ endif spec_config.h: spec_config.h.pre $(SED) -e "s|@@LOCALSTATEDIR@@|$(localstatedir)|" spec_config.h.pre >$@ -d2_messages.h d2_messages.cc: d2_messages.mes +d2_messages.h d2_messages.cc: s-messages + +s-messages: d2_messages.mes $(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/bin/d2/d2_messages.mes + touch $@ BUILT_SOURCES = spec_config.h d2_messages.h d2_messages.cc diff --git a/src/bin/dhcp4/Makefile.am b/src/bin/dhcp4/Makefile.am index 80b7fc3284..774d5b437b 100644 --- a/src/bin/dhcp4/Makefile.am +++ b/src/bin/dhcp4/Makefile.am @@ -16,7 +16,7 @@ endif pkglibexecdir = $(libexecdir)/@PACKAGE@ -CLEANFILES = *.gcno *.gcda spec_config.h dhcp4_messages.h dhcp4_messages.cc +CLEANFILES = *.gcno *.gcda spec_config.h dhcp4_messages.h dhcp4_messages.cc s-messages man_MANS = b10-dhcp4.8 DISTCLEANFILES = $(man_MANS) @@ -39,8 +39,11 @@ endif spec_config.h: spec_config.h.pre $(SED) -e "s|@@LOCALSTATEDIR@@|$(localstatedir)|" spec_config.h.pre >$@ -dhcp4_messages.h dhcp4_messages.cc: dhcp4_messages.mes +dhcp4_messages.h dhcp4_messages.cc: s-messages + +s-messages: dhcp4_messages.mes $(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/bin/dhcp4/dhcp4_messages.mes + touch $@ BUILT_SOURCES = spec_config.h dhcp4_messages.h dhcp4_messages.cc diff --git a/src/bin/dhcp6/Makefile.am b/src/bin/dhcp6/Makefile.am index 9b7972b363..9c7a5dfccc 100644 --- a/src/bin/dhcp6/Makefile.am +++ b/src/bin/dhcp6/Makefile.am @@ -17,7 +17,7 @@ endif pkglibexecdir = $(libexecdir)/@PACKAGE@ -CLEANFILES = spec_config.h dhcp6_messages.h dhcp6_messages.cc +CLEANFILES = spec_config.h dhcp6_messages.h dhcp6_messages.cc s-messages man_MANS = b10-dhcp6.8 DISTCLEANFILES = $(man_MANS) @@ -41,8 +41,11 @@ endif spec_config.h: spec_config.h.pre $(SED) -e "s|@@LOCALSTATEDIR@@|$(localstatedir)|" spec_config.h.pre >$@ -dhcp6_messages.h dhcp6_messages.cc: dhcp6_messages.mes +dhcp6_messages.h dhcp6_messages.cc: s-messages + +s-messages: dhcp6_messages.mes $(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/bin/dhcp6/dhcp6_messages.mes + touch $@ BUILT_SOURCES = spec_config.h dhcp6_messages.h dhcp6_messages.cc diff --git a/src/bin/resolver/Makefile.am b/src/bin/resolver/Makefile.am index 30ecd581cd..36a302e685 100644 --- a/src/bin/resolver/Makefile.am +++ b/src/bin/resolver/Makefile.am @@ -20,7 +20,7 @@ pkglibexecdir = $(libexecdir)/@PACKAGE@ CLEANFILES = *.gcno *.gcda CLEANFILES += resolver.spec spec_config.h -CLEANFILES += resolver_messages.cc resolver_messages.h +CLEANFILES += resolver_messages.cc resolver_messages.h s-messages man_MANS = b10-resolver.8 DISTCLEANFILES = $(man_MANS) @@ -46,9 +46,11 @@ spec_config.h: spec_config.h.pre $(SED) -e "s|@@LOCALSTATEDIR@@|$(localstatedir)|" spec_config.h.pre >$@ # Define rule to build logging source files from message file -resolver_messages.h resolver_messages.cc: resolver_messages.mes - $(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/bin/resolver/resolver_messages.mes +resolver_messages.h resolver_messages.cc: s-messages +s-messages: resolver_messages.mes + $(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/bin/resolver/resolver_messages.mes + touch $@ BUILT_SOURCES = spec_config.h resolver_messages.cc resolver_messages.h diff --git a/src/lib/asiodns/Makefile.am b/src/lib/asiodns/Makefile.am index 321de8b9d1..930c870fee 100644 --- a/src/lib/asiodns/Makefile.am +++ b/src/lib/asiodns/Makefile.am @@ -8,11 +8,14 @@ AM_CPPFLAGS += -I$(top_srcdir)/src/lib/util -I$(top_builddir)/src/lib/util AM_CXXFLAGS = $(B10_CXXFLAGS) -CLEANFILES = *.gcno *.gcda asiodns_messages.h asiodns_messages.cc +CLEANFILES = *.gcno *.gcda asiodns_messages.h asiodns_messages.cc s-messages # Define rule to build logging source files from message file -asiodns_messages.h asiodns_messages.cc: asiodns_messages.mes +asiodns_messages.h asiodns_messages.cc: s-messages + +s-messages: asiodns_messages.mes $(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/lib/asiodns/asiodns_messages.mes + touch $@ BUILT_SOURCES = asiodns_messages.h asiodns_messages.cc diff --git a/src/lib/cache/Makefile.am b/src/lib/cache/Makefile.am index 00ca16edc0..7a84dd639f 100644 --- a/src/lib/cache/Makefile.am +++ b/src/lib/cache/Makefile.am @@ -36,9 +36,12 @@ nodist_libb10_cache_la_SOURCES = cache_messages.cc cache_messages.h BUILT_SOURCES = cache_messages.cc cache_messages.h -cache_messages.cc cache_messages.h: cache_messages.mes +cache_messages.cc cache_messages.h: s-messages + +s-messages: cache_messages.mes $(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/lib/cache/cache_messages.mes + touch $@ -CLEANFILES = *.gcno *.gcda cache_messages.cc cache_messages.h +CLEANFILES = *.gcno *.gcda cache_messages.cc cache_messages.h s-messages EXTRA_DIST = cache_messages.mes diff --git a/src/lib/cc/Makefile.am b/src/lib/cc/Makefile.am index 06e9309f3f..1b1e61126c 100644 --- a/src/lib/cc/Makefile.am +++ b/src/lib/cc/Makefile.am @@ -29,13 +29,16 @@ nodist_libb10_cc_la_SOURCES += proto_defs.h libb10_cc_la_LIBADD = $(top_builddir)/src/lib/log/libb10-log.la CLEANFILES = *.gcno *.gcda session_config.h cc_messages.cc cc_messages.h \ - proto_defs.h + proto_defs.h s-messages session_config.h: session_config.h.pre $(SED) -e "s|@@LOCALSTATEDIR@@|$(localstatedir)|" session_config.h.pre >$@ -cc_messages.cc cc_messages.h: cc_messages.mes +cc_messages.cc cc_messages.h: s-messages + +s-messages: cc_messages.mes $(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/lib/cc/cc_messages.mes + touch $@ BUILT_SOURCES = session_config.h cc_messages.cc cc_messages.h proto_defs.h diff --git a/src/lib/config/Makefile.am b/src/lib/config/Makefile.am index b4fc2e0c89..9820f08289 100644 --- a/src/lib/config/Makefile.am +++ b/src/lib/config/Makefile.am @@ -6,8 +6,11 @@ AM_CPPFLAGS += -I$(top_srcdir)/src/lib/log -I$(top_builddir)/src/lib/log AM_CPPFLAGS += $(BOOST_INCLUDES) # Define rule to build logging source files from message file -config_messages.h config_messages.cc: config_messages.mes +config_messages.h config_messages.cc: s-messages + +s-messages: config_messages.mes $(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/lib/config/config_messages.mes + touch $@ BUILT_SOURCES = config_messages.h config_messages.cc @@ -27,4 +30,4 @@ nodist_libb10_cfgclient_la_SOURCES = config_messages.h config_messages.cc # The message file should be in the distribution. EXTRA_DIST = config_messages.mes -CLEANFILES = *.gcno *.gcda config_messages.h config_messages.cc +CLEANFILES = *.gcno *.gcda config_messages.h config_messages.cc s-messages diff --git a/src/lib/datasrc/Makefile.am b/src/lib/datasrc/Makefile.am index 5422f7dcde..e358c05b5f 100644 --- a/src/lib/datasrc/Makefile.am +++ b/src/lib/datasrc/Makefile.am @@ -22,6 +22,7 @@ CLEANFILES = *.gcno *.gcda datasrc_messages.h datasrc_messages.cc CLEANFILES += sqlite3_datasrc_messages.h sqlite3_datasrc_messages.cc CLEANFILES += datasrc_config.h CLEANFILES += static.zone +CLEANFILES += s-messages1 s-messages2 lib_LTLIBRARIES = libb10-datasrc.la libb10_datasrc_la_SOURCES = exceptions.h @@ -65,10 +66,17 @@ libb10_datasrc_la_LIBADD += $(SQLITE_LIBS) BUILT_SOURCES = datasrc_config.h datasrc_messages.h datasrc_messages.cc BUILT_SOURCES += sqlite3_datasrc_messages.h sqlite3_datasrc_messages.cc -datasrc_messages.h datasrc_messages.cc: Makefile datasrc_messages.mes +datasrc_messages.h datasrc_messages.cc: s-messages1 + +s-messages1: Makefile datasrc_messages.mes $(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/lib/datasrc/datasrc_messages.mes -sqlite3_datasrc_messages.h sqlite3_datasrc_messages.cc: Makefile sqlite3_datasrc_messages.mes + touch $@ + +sqlite3_datasrc_messages.h sqlite3_datasrc_messages.cc: s-messages2 + +s-messages2: Makefile sqlite3_datasrc_messages.mes $(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/lib/datasrc/sqlite3_datasrc_messages.mes + touch $@ EXTRA_DIST = datasrc_messages.mes sqlite3_datasrc_messages.mes static.zone.pre diff --git a/src/lib/datasrc/memory/Makefile.am b/src/lib/datasrc/memory/Makefile.am index 434eaf2e3b..197f3faa4f 100644 --- a/src/lib/datasrc/memory/Makefile.am +++ b/src/lib/datasrc/memory/Makefile.am @@ -40,8 +40,11 @@ nodist_libdatasrc_memory_la_SOURCES = memory_messages.h memory_messages.cc EXTRA_DIST = rdata_serialization_priv.cc BUILT_SOURCES = memory_messages.h memory_messages.cc -memory_messages.h memory_messages.cc: Makefile memory_messages.mes +memory_messages.h memory_messages.cc: s-messages + +s-messages: Makefile memory_messages.mes $(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/lib/datasrc/memory/memory_messages.mes + touch $@ EXTRA_DIST += memory_messages.mes -CLEANFILES += memory_messages.h memory_messages.cc +CLEANFILES += memory_messages.h memory_messages.cc s-messages diff --git a/src/lib/dhcp_ddns/Makefile.am b/src/lib/dhcp_ddns/Makefile.am index 546a9820e4..552f6d97c5 100644 --- a/src/lib/dhcp_ddns/Makefile.am +++ b/src/lib/dhcp_ddns/Makefile.am @@ -12,8 +12,11 @@ AM_CXXFLAGS += $(WARNING_NO_MISSING_FIELD_INITIALIZERS_CFLAG) # Define rule to build logging source files from message file -dhcp_ddns_messages.h dhcp_ddns_messages.cc: dhcp_ddns_messages.mes +dhcp_ddns_messages.h dhcp_ddns_messages.cc: s-messages + +s-messages: dhcp_ddns_messages.mes $(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/lib/dhcp_ddns/dhcp_ddns_messages.mes + touch $@ # Tell automake that the message files are built as part of the build process # (so that they are built before the main library is built). @@ -23,7 +26,7 @@ BUILT_SOURCES = dhcp_ddns_messages.h dhcp_ddns_messages.cc EXTRA_DIST = dhcp_ddns_messages.mes libdhcp_ddns.dox # Get rid of generated message files on a clean -CLEANFILES = *.gcno *.gcda dhcp_ddns_messages.h dhcp_ddns_messages.cc +CLEANFILES = *.gcno *.gcda dhcp_ddns_messages.h dhcp_ddns_messages.cc s-messages lib_LTLIBRARIES = libb10-dhcp_ddns.la libb10_dhcp_ddns_la_SOURCES = diff --git a/src/lib/dhcpsrv/Makefile.am b/src/lib/dhcpsrv/Makefile.am index 5390a01753..a738abac5e 100644 --- a/src/lib/dhcpsrv/Makefile.am +++ b/src/lib/dhcpsrv/Makefile.am @@ -11,8 +11,11 @@ endif AM_CXXFLAGS = $(B10_CXXFLAGS) # Define rule to build logging source files from message file -dhcpsrv_messages.h dhcpsrv_messages.cc: dhcpsrv_messages.mes +dhcpsrv_messages.h dhcpsrv_messages.cc: s-messages + +s-messages: dhcpsrv_messages.mes $(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/lib/dhcpsrv/dhcpsrv_messages.mes + touch $@ # Tell Automake that the dhcpsrv_messages.{cc,h} source files are created in the # build process, so it must create these before doing anything else. Although @@ -29,7 +32,7 @@ BUILT_SOURCES = dhcpsrv_messages.h dhcpsrv_messages.cc AM_CXXFLAGS += $(WARNING_NO_MISSING_FIELD_INITIALIZERS_CFLAG) # Make sure the generated files are deleted in a "clean" operation -CLEANFILES = *.gcno *.gcda dhcpsrv_messages.h dhcpsrv_messages.cc +CLEANFILES = *.gcno *.gcda dhcpsrv_messages.h dhcpsrv_messages.cc s-messages lib_LTLIBRARIES = libb10-dhcpsrv.la libb10_dhcpsrv_la_SOURCES = diff --git a/src/lib/dns/Makefile.am b/src/lib/dns/Makefile.am index bbf33edaea..9d4296e2ac 100644 --- a/src/lib/dns/Makefile.am +++ b/src/lib/dns/Makefile.am @@ -7,7 +7,7 @@ AM_CPPFLAGS += $(BOOST_INCLUDES) AM_CXXFLAGS = $(B10_CXXFLAGS) CLEANFILES = *.gcno *.gcda -CLEANFILES += rrclass.h rrtype.h rrparamregistry.cc rdataclass.h rdataclass.cc +CLEANFILES += rrclass.h rrtype.h rrparamregistry.cc rdataclass.h rdataclass.cc s-rdatacode # These two are created with rrtype/class.h, so not explicitly listed in # BUILT_SOURCES. CLEANFILES += python/rrtype_constants_inc.cc @@ -157,8 +157,12 @@ nodist_libb10_dns___la_SOURCES = rdataclass.cc rrparamregistry.cc rrclass.h: rrclass-placeholder.h rrtype.h: rrtype-placeholder.h rrparamregistry.cc: rrparamregistry-placeholder.cc -rrclass.h rrtype.h rrparamregistry.cc rdataclass.h rdataclass.cc: Makefile + +s-rdatacode: $(PYTHON) ./gen-rdatacode.py + touch $@ + +rrclass.h rrtype.h rrparamregistry.cc rdataclass.h rdataclass.cc: Makefile s-rdatacode libdns___includedir = $(includedir)/$(PACKAGE_NAME)/dns libdns___include_HEADERS = \ diff --git a/src/lib/hooks/Makefile.am b/src/lib/hooks/Makefile.am index d9ea39e4df..4f81e67c1a 100644 --- a/src/lib/hooks/Makefile.am +++ b/src/lib/hooks/Makefile.am @@ -12,8 +12,11 @@ AM_CXXFLAGS += $(WARNING_NO_MISSING_FIELD_INITIALIZERS_CFLAG) # Define rule to build logging source files from message file -hooks_messages.h hooks_messages.cc: hooks_messages.mes +hooks_messages.h hooks_messages.cc: s-messages + +s-messages: hooks_messages.mes $(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/lib/hooks/hooks_messages.mes + touch $@ # Tell automake that the message files are built as part of the build process # (so that they are built before the main library is built). @@ -23,7 +26,7 @@ BUILT_SOURCES = hooks_messages.h hooks_messages.cc EXTRA_DIST = hooks_messages.mes # Get rid of generated message files on a clean -CLEANFILES = *.gcno *.gcda hooks_messages.h hooks_messages.cc +CLEANFILES = *.gcno *.gcda hooks_messages.h hooks_messages.cc s-messages lib_LTLIBRARIES = libb10-hooks.la libb10_hooks_la_SOURCES = diff --git a/src/lib/log/tests/Makefile.am b/src/lib/log/tests/Makefile.am index 92303e03dc..a26b348edf 100644 --- a/src/lib/log/tests/Makefile.am +++ b/src/lib/log/tests/Makefile.am @@ -14,10 +14,13 @@ CLEANFILES = *.gcno *.gcda *.lock EXTRA_DIST = log_test_messages.mes BUILT_SOURCES = log_test_messages.h log_test_messages.cc -log_test_messages.h log_test_messages.cc: log_test_messages.mes +log_test_messages.h log_test_messages.cc: s-messages + +s-messages: log_test_messages.mes $(AM_V_GEN) $(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/lib/log/tests/log_test_messages.mes + touch $@ -CLEANFILES += log_test_messages.h log_test_messages.cc +CLEANFILES += log_test_messages.h log_test_messages.cc s-messages noinst_PROGRAMS = logger_example logger_example_SOURCES = logger_example.cc diff --git a/src/lib/nsas/Makefile.am b/src/lib/nsas/Makefile.am index dd30593a73..d38cf1ad3a 100644 --- a/src/lib/nsas/Makefile.am +++ b/src/lib/nsas/Makefile.am @@ -22,8 +22,11 @@ AM_CXXFLAGS += -Wno-unused-parameter endif # Define rule to build logging source files from message file -nsas_messages.h nsas_messages.cc: nsas_messages.mes +nsas_messages.h nsas_messages.cc: s-messages + +s-messages: nsas_messages.mes $(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/lib/nsas/nsas_messages.mes + touch $@ # What is being built. lib_LTLIBRARIES = libb10-nsas.la @@ -59,4 +62,4 @@ nodist_libb10_nsas_la_SOURCES = nsas_messages.h nsas_messages.cc EXTRA_DIST = nsas_messages.mes # Make sure that the generated files are got rid of in a clean operation -CLEANFILES = *.gcno *.gcda nsas_messages.h nsas_messages.cc +CLEANFILES = *.gcno *.gcda nsas_messages.h nsas_messages.cc s-messages diff --git a/src/lib/resolve/Makefile.am b/src/lib/resolve/Makefile.am index 0016684d85..6c047440a7 100644 --- a/src/lib/resolve/Makefile.am +++ b/src/lib/resolve/Makefile.am @@ -8,8 +8,11 @@ AM_CPPFLAGS += $(SQLITE_CFLAGS) AM_CXXFLAGS = $(B10_CXXFLAGS) # Define rule to build logging source files from message file -resolve_messages.h resolve_messages.cc: resolve_messages.mes +resolve_messages.h resolve_messages.cc: s-messages + +s-messages: resolve_messages.mes $(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/lib/resolve/resolve_messages.mes + touch $@ # Tell Automake that the nsasdef.{cc,h} source files are created in the build # process, so it must create these before doing anything else. Although they @@ -19,7 +22,7 @@ resolve_messages.h resolve_messages.cc: resolve_messages.mes # present when they are compiled), the safest option is to create it first. BUILT_SOURCES = resolve_messages.h resolve_messages.cc -CLEANFILES = *.gcno *.gcda resolve_messages.cc resolve_messages.h +CLEANFILES = *.gcno *.gcda resolve_messages.cc resolve_messages.h s-messages lib_LTLIBRARIES = libb10-resolve.la libb10_resolve_la_SOURCES = resolve.h resolve.cc diff --git a/src/lib/server_common/Makefile.am b/src/lib/server_common/Makefile.am index cf9059abb3..9ea55d8cbe 100644 --- a/src/lib/server_common/Makefile.am +++ b/src/lib/server_common/Makefile.am @@ -33,9 +33,12 @@ libb10_server_common_la_LIBADD += $(top_builddir)/src/lib/acl/libb10-acl.la libb10_server_common_la_LIBADD += $(top_builddir)/src/lib/dns/libb10-dns++.la libb10_server_common_la_LIBADD += $(top_builddir)/src/lib/util/io/libb10-util-io.la BUILT_SOURCES = server_common_messages.h server_common_messages.cc -server_common_messages.h server_common_messages.cc: server_common_messages.mes +server_common_messages.h server_common_messages.cc: s-messages + +s-messages: server_common_messages.mes $(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/lib/server_common/server_common_messages.mes + touch $@ EXTRA_DIST = server_common_messages.mes -CLEANFILES = *.gcno *.gcda server_common_messages.h server_common_messages.cc +CLEANFILES = *.gcno *.gcda server_common_messages.h server_common_messages.cc s-messages diff --git a/src/lib/util/tests/Makefile.am b/src/lib/util/tests/Makefile.am index ab85fa2021..d8f3d305f1 100644 --- a/src/lib/util/tests/Makefile.am +++ b/src/lib/util/tests/Makefile.am @@ -50,8 +50,7 @@ run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS) run_unittests_LDADD = $(top_builddir)/src/lib/util/libb10-util.la run_unittests_LDADD += $(top_builddir)/src/lib/util/io/libb10-util-io.la -run_unittests_LDADD += \ - $(top_builddir)/src/lib/util/unittests/libutil_unittests.la +run_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libb10-exceptions.la run_unittests_LDADD += $(GTEST_LDADD) endif diff --git a/src/lib/util/threads/tests/Makefile.am b/src/lib/util/threads/tests/Makefile.am index a12d221d18..80c6ece780 100644 --- a/src/lib/util/threads/tests/Makefile.am +++ b/src/lib/util/threads/tests/Makefile.am @@ -29,8 +29,7 @@ run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS) $(PTHREAD_LDFLAGS) run_unittests_LDADD = $(top_builddir)/src/lib/util/threads/libb10-threads.la -run_unittests_LDADD += \ - $(top_builddir)/src/lib/util/unittests/libutil_unittests.la +run_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la run_unittests_LDADD += $(GTEST_LDADD) endif -- cgit v1.2.3 From 2d83a3a525c255b565aa57e3bd5efce5ca38a269 Mon Sep 17 00:00:00 2001 From: Kean Johnston Date: Thu, 10 Oct 2013 14:59:55 +0200 Subject: [3073] Add empty() member function to Element for element lists. It has been asserted that using empty() is more efficient than using size() > 0 due to the possible extra work size() has to do. So provide an empty() function, which matches the underlying Boost implementation. --- src/lib/cc/data.cc | 5 +++++ src/lib/cc/data.h | 4 ++++ src/lib/cc/session.cc | 2 +- src/lib/cc/tests/data_unittests.cc | 6 ++++++ src/lib/config/ccsession.cc | 2 +- src/lib/config/tests/fake_session.cc | 8 ++++---- src/lib/datasrc/cache_config.cc | 4 ++++ src/lib/datasrc/client_list.cc | 5 +++++ src/lib/server_common/portconfig.cc | 3 ++- 9 files changed, 32 insertions(+), 7 deletions(-) (limited to 'src/lib/config') diff --git a/src/lib/cc/data.cc b/src/lib/cc/data.cc index 35189392ea..5f87d7c478 100644 --- a/src/lib/cc/data.cc +++ b/src/lib/cc/data.cc @@ -145,6 +145,11 @@ Element::size() const { isc_throw(TypeError, "size() called on a non-list Element"); } +bool +Element::empty() const { + isc_throw(TypeError, "empty() called on a non-list Element"); +} + ConstElementPtr Element::get(const std::string&) const { isc_throw(TypeError, "get(string) called on a non-map Element"); diff --git a/src/lib/cc/data.h b/src/lib/cc/data.h index 805060752c..bea9dbb626 100644 --- a/src/lib/cc/data.h +++ b/src/lib/cc/data.h @@ -210,6 +210,9 @@ public: /// Returns the number of elements in the list. virtual size_t size() const; + + /// Return true if there are no elements in the list. + virtual bool empty() const; //@} @@ -479,6 +482,7 @@ public: void remove(int i) { l.erase(l.begin() + i); }; void toJSON(std::ostream& ss) const; size_t size() const { return (l.size()); } + bool empty() const { return (l.empty()); } bool equals(const Element& other) const; }; diff --git a/src/lib/cc/session.cc b/src/lib/cc/session.cc index cb1ca39afc..0a2f11d575 100644 --- a/src/lib/cc/session.cc +++ b/src/lib/cc/session.cc @@ -535,7 +535,7 @@ Session::reply(ConstElementPtr envelope, ConstElementPtr newmsg) { bool Session::hasQueuedMsgs() const { - return (impl_->queue_->size() > 0); + return (!impl_->queue_->empty()); } void diff --git a/src/lib/cc/tests/data_unittests.cc b/src/lib/cc/tests/data_unittests.cc index a60c994a1a..9568884d45 100644 --- a/src/lib/cc/tests/data_unittests.cc +++ b/src/lib/cc/tests/data_unittests.cc @@ -418,6 +418,7 @@ TEST(Element, create_and_value_throws) { EXPECT_THROW(el->add(el), TypeError); EXPECT_THROW(el->remove(1), TypeError); EXPECT_THROW(el->size(), TypeError); + EXPECT_THROW(el->empty(), TypeError); EXPECT_THROW(el->get("foo"), TypeError); EXPECT_THROW(el->set("foo", el), TypeError); EXPECT_THROW(el->remove("foo"), TypeError); @@ -441,6 +442,7 @@ TEST(Element, create_and_value_throws) { EXPECT_THROW(el->add(el), TypeError); EXPECT_THROW(el->remove(1), TypeError); EXPECT_THROW(el->size(), TypeError); + EXPECT_THROW(el->empty(), TypeError); EXPECT_THROW(el->get("foo"), TypeError); EXPECT_THROW(el->set("foo", el), TypeError); EXPECT_THROW(el->remove("foo"), TypeError); @@ -464,6 +466,7 @@ TEST(Element, create_and_value_throws) { EXPECT_THROW(el->add(el), TypeError); EXPECT_THROW(el->remove(1), TypeError); EXPECT_THROW(el->size(), TypeError); + EXPECT_THROW(el->empty(), TypeError); EXPECT_THROW(el->get("foo"), TypeError); EXPECT_THROW(el->set("foo", el), TypeError); EXPECT_THROW(el->remove("foo"), TypeError); @@ -487,6 +490,7 @@ TEST(Element, create_and_value_throws) { EXPECT_THROW(el->add(el), TypeError); EXPECT_THROW(el->remove(1), TypeError); EXPECT_THROW(el->size(), TypeError); + EXPECT_THROW(el->empty(), TypeError); EXPECT_THROW(el->get("foo"), TypeError); EXPECT_THROW(el->set("foo", el), TypeError); EXPECT_THROW(el->remove("foo"), TypeError); @@ -497,8 +501,10 @@ TEST(Element, create_and_value_throws) { testGetValueList(); el = Element::createList(); + EXPECT_TRUE(el->empty()); v.push_back(Element::create(1)); EXPECT_TRUE(el->setValue(v)); + EXPECT_FALSE(el->empty()); EXPECT_EQ("[ 1 ]", el->str()); testGetValueMap(); diff --git a/src/lib/config/ccsession.cc b/src/lib/config/ccsession.cc index 780fe95a15..cbe3a360e0 100644 --- a/src/lib/config/ccsession.cc +++ b/src/lib/config/ccsession.cc @@ -144,7 +144,7 @@ parseCommand(ConstElementPtr& arg, ConstElementPtr command) { command->contains(isc::cc::CC_PAYLOAD_COMMAND)) { ConstElementPtr cmd = command->get(isc::cc::CC_PAYLOAD_COMMAND); if (cmd->getType() == Element::list && - cmd->size() > 0 && + !cmd->empty() && cmd->get(0)->getType() == Element::string) { if (cmd->size() > 1) { arg = cmd->get(1); diff --git a/src/lib/config/tests/fake_session.cc b/src/lib/config/tests/fake_session.cc index e6d569e732..c2fba57577 100644 --- a/src/lib/config/tests/fake_session.cc +++ b/src/lib/config/tests/fake_session.cc @@ -104,7 +104,7 @@ FakeSession::recvmsg(ConstElementPtr& msg, bool nonblock, int) { //cout << "[XX] client asks for message " << endl; if (messages_ && messages_->getType() == Element::list && - messages_->size() > 0) { + !messages_->empty()) { msg = messages_->get(0); messages_->remove(0); } else { @@ -127,7 +127,7 @@ FakeSession::recvmsg(ConstElementPtr& env, ConstElementPtr& msg, bool nonblock, env = ElementPtr(); if (messages_ && messages_->getType() == Element::list && - messages_->size() > 0) { + !messages_->empty()) { // do we need initial message to have env[group] and [to] too? msg = messages_->get(0); messages_->remove(0); @@ -210,13 +210,13 @@ FakeSession::reply(ConstElementPtr envelope, ConstElementPtr newmsg) { bool FakeSession::hasQueuedMsgs() const { - return (msg_queue_ && msg_queue_->size() > 0); + return (msg_queue_ && !msg_queue_->empty()); } ConstElementPtr FakeSession::getFirstMessage(std::string& group, std::string& to) const { ConstElementPtr el; - if (msg_queue_ && msg_queue_->size() > 0) { + if (msg_queue_ && !msg_queue_->empty()) { el = msg_queue_->get(0); msg_queue_->remove(0); group = el->get(0)->stringValue(); diff --git a/src/lib/datasrc/cache_config.cc b/src/lib/datasrc/cache_config.cc index ec3cfeba82..86c0125d31 100644 --- a/src/lib/datasrc/cache_config.cc +++ b/src/lib/datasrc/cache_config.cc @@ -106,6 +106,10 @@ CacheConfig::CacheConfig(const std::string& datasrc_type, } const ConstElementPtr zones = datasrc_conf.get("cache-zones"); + if (zones->empty()) { + return; + } + for (size_t i = 0; i < zones->size(); ++i) { const dns::Name zone_name(zones->get(i)->stringValue()); if (!zone_config_.insert(Zones::value_type(zone_name, diff --git a/src/lib/datasrc/client_list.cc b/src/lib/datasrc/client_list.cc index 531821ceb5..aaa5a6fe75 100644 --- a/src/lib/datasrc/client_list.cc +++ b/src/lib/datasrc/client_list.cc @@ -83,6 +83,11 @@ ConfigurableClientList::configure(const ConstElementPtr& config, if (!config) { isc_throw(isc::BadValue, "NULL configuration passed"); } + + if (config->empty()) { + return; + } + // TODO: Implement recycling from the old configuration. size_t i(0); // Outside of the try to be able to access it in the catch try { diff --git a/src/lib/server_common/portconfig.cc b/src/lib/server_common/portconfig.cc index 6120c7ddbf..4c47cc0271 100644 --- a/src/lib/server_common/portconfig.cc +++ b/src/lib/server_common/portconfig.cc @@ -37,7 +37,8 @@ parseAddresses(isc::data::ConstElementPtr addresses, { AddressList result; if (addresses) { - if (addresses->getType() == Element::list) { + if (addresses->getType() == Element::list && + !addresses->empty() ) { for (size_t i(0); i < addresses->size(); ++ i) { ConstElementPtr addrPair(addresses->get(i)); ConstElementPtr addr(addrPair->get("address")); -- cgit v1.2.3 From c27219ff78ee2927a4ab44e4f2a0020f7310dec1 Mon Sep 17 00:00:00 2001 From: Mukund Sivaraman Date: Mon, 20 Jan 2014 10:07:14 +0530 Subject: Update .gitignore files --- src/bin/auth/.gitignore | 2 ++ src/bin/d2/.gitignore | 1 + src/bin/dhcp4/.gitignore | 1 + src/bin/dhcp4/tests/.gitignore | 3 +++ src/bin/dhcp6/.gitignore | 1 + src/bin/dhcp6/tests/.gitignore | 3 +++ src/bin/resolver/.gitignore | 1 + src/hooks/dhcp/user_chk/tests/.gitignore | 2 ++ src/lib/asiodns/.gitignore | 1 + src/lib/cache/.gitignore | 1 + src/lib/cc/.gitignore | 1 + src/lib/config/.gitignore | 1 + src/lib/datasrc/.gitignore | 2 ++ src/lib/datasrc/memory/.gitignore | 1 + src/lib/dhcp_ddns/.gitignore | 1 + src/lib/dhcpsrv/.gitignore | 1 + src/lib/dhcpsrv/tests/.gitignore | 1 + src/lib/dns/.gitignore | 1 + src/lib/hooks/.gitignore | 1 + src/lib/log/tests/.gitignore | 1 + src/lib/nsas/.gitignore | 1 + src/lib/resolve/.gitignore | 1 + src/lib/server_common/.gitignore | 1 + 23 files changed, 30 insertions(+) create mode 100644 src/hooks/dhcp/user_chk/tests/.gitignore (limited to 'src/lib/config') diff --git a/src/bin/auth/.gitignore b/src/bin/auth/.gitignore index c3db95bd31..c090cbada8 100644 --- a/src/bin/auth/.gitignore +++ b/src/bin/auth/.gitignore @@ -11,3 +11,5 @@ /gen-statisticsitems.py.pre /statistics.cc /statistics_items.h +/s-genstats +/s-messages diff --git a/src/bin/d2/.gitignore b/src/bin/d2/.gitignore index d1478024d8..9726436a1a 100644 --- a/src/bin/d2/.gitignore +++ b/src/bin/d2/.gitignore @@ -4,3 +4,4 @@ /d2_messages.h /spec_config.h /spec_config.h.pre +/s-messages diff --git a/src/bin/dhcp4/.gitignore b/src/bin/dhcp4/.gitignore index 86965b9f56..2ca0e8093f 100644 --- a/src/bin/dhcp4/.gitignore +++ b/src/bin/dhcp4/.gitignore @@ -4,3 +4,4 @@ /dhcp4_messages.h /spec_config.h /spec_config.h.pre +/s-messages diff --git a/src/bin/dhcp4/tests/.gitignore b/src/bin/dhcp4/tests/.gitignore index 5d14dacb3f..5983892923 100644 --- a/src/bin/dhcp4/tests/.gitignore +++ b/src/bin/dhcp4/tests/.gitignore @@ -1 +1,4 @@ /dhcp4_unittests +/marker_file.h +/test_data_files_config.h +/test_libraries.h diff --git a/src/bin/dhcp6/.gitignore b/src/bin/dhcp6/.gitignore index 58781893aa..dae9039523 100644 --- a/src/bin/dhcp6/.gitignore +++ b/src/bin/dhcp6/.gitignore @@ -4,3 +4,4 @@ /dhcp6_messages.h /spec_config.h /spec_config.h.pre +/s-messages diff --git a/src/bin/dhcp6/tests/.gitignore b/src/bin/dhcp6/tests/.gitignore index e170d18915..f4ca7830e1 100644 --- a/src/bin/dhcp6/tests/.gitignore +++ b/src/bin/dhcp6/tests/.gitignore @@ -1 +1,4 @@ /dhcp6_unittests +/marker_file.h +/test_data_files_config.h +/test_libraries.h diff --git a/src/bin/resolver/.gitignore b/src/bin/resolver/.gitignore index b3abbc9b7c..a4c02b0a7b 100644 --- a/src/bin/resolver/.gitignore +++ b/src/bin/resolver/.gitignore @@ -6,3 +6,4 @@ /spec_config.h /spec_config.h.pre /b10-resolver.8 +/s-messages diff --git a/src/hooks/dhcp/user_chk/tests/.gitignore b/src/hooks/dhcp/user_chk/tests/.gitignore new file mode 100644 index 0000000000..32b5d22615 --- /dev/null +++ b/src/hooks/dhcp/user_chk/tests/.gitignore @@ -0,0 +1,2 @@ +/libdhcp_user_chk_unittests +/test_data_files_config.h diff --git a/src/lib/asiodns/.gitignore b/src/lib/asiodns/.gitignore index dedf17ea1f..189824e16d 100644 --- a/src/lib/asiodns/.gitignore +++ b/src/lib/asiodns/.gitignore @@ -1,2 +1,3 @@ /asiodns_messages.cc /asiodns_messages.h +/s-messages diff --git a/src/lib/cache/.gitignore b/src/lib/cache/.gitignore index a33f3f03c4..65ae291192 100644 --- a/src/lib/cache/.gitignore +++ b/src/lib/cache/.gitignore @@ -1,2 +1,3 @@ /cache_messages.cc /cache_messages.h +/s-messages diff --git a/src/lib/cc/.gitignore b/src/lib/cc/.gitignore index d1e56dfa5c..d375181484 100644 --- a/src/lib/cc/.gitignore +++ b/src/lib/cc/.gitignore @@ -3,3 +3,4 @@ /proto_defs.h /session_config.h /session_config.h.pre +/s-messages diff --git a/src/lib/config/.gitignore b/src/lib/config/.gitignore index c7ec9d3565..d666f2469a 100644 --- a/src/lib/config/.gitignore +++ b/src/lib/config/.gitignore @@ -1,2 +1,3 @@ /config_messages.cc /config_messages.h +/s-messages diff --git a/src/lib/datasrc/.gitignore b/src/lib/datasrc/.gitignore index 4b199ed505..0d473f3352 100644 --- a/src/lib/datasrc/.gitignore +++ b/src/lib/datasrc/.gitignore @@ -5,3 +5,5 @@ /static.zone /sqlite3_datasrc_messages.cc /sqlite3_datasrc_messages.h +/s-messages1 +/s-messages2 diff --git a/src/lib/datasrc/memory/.gitignore b/src/lib/datasrc/memory/.gitignore index fbb638179f..89122b9402 100644 --- a/src/lib/datasrc/memory/.gitignore +++ b/src/lib/datasrc/memory/.gitignore @@ -1,2 +1,3 @@ /memory_messages.cc /memory_messages.h +/s-messages diff --git a/src/lib/dhcp_ddns/.gitignore b/src/lib/dhcp_ddns/.gitignore index 6388b8cdd6..c632c2e100 100644 --- a/src/lib/dhcp_ddns/.gitignore +++ b/src/lib/dhcp_ddns/.gitignore @@ -1,2 +1,3 @@ /dhcp_ddns_messages.cc /dhcp_ddns_messages.h +/s-messages diff --git a/src/lib/dhcpsrv/.gitignore b/src/lib/dhcpsrv/.gitignore index 0b02c01a50..1f085382ce 100644 --- a/src/lib/dhcpsrv/.gitignore +++ b/src/lib/dhcpsrv/.gitignore @@ -1,2 +1,3 @@ /dhcpsrv_messages.cc /dhcpsrv_messages.h +/s-messages diff --git a/src/lib/dhcpsrv/tests/.gitignore b/src/lib/dhcpsrv/tests/.gitignore index 7add7fb019..33ac8d9e86 100644 --- a/src/lib/dhcpsrv/tests/.gitignore +++ b/src/lib/dhcpsrv/tests/.gitignore @@ -1 +1,2 @@ /libdhcpsrv_unittests +/test_libraries.h diff --git a/src/lib/dns/.gitignore b/src/lib/dns/.gitignore index cdf707c3a1..9606daca0b 100644 --- a/src/lib/dns/.gitignore +++ b/src/lib/dns/.gitignore @@ -4,3 +4,4 @@ /rrclass.h /rrparamregistry.cc /rrtype.h +/s-rdatacode diff --git a/src/lib/hooks/.gitignore b/src/lib/hooks/.gitignore index 5a9364c623..89adbe1baf 100644 --- a/src/lib/hooks/.gitignore +++ b/src/lib/hooks/.gitignore @@ -1,2 +1,3 @@ /hooks_messages.cc /hooks_messages.h +/s-messages diff --git a/src/lib/log/tests/.gitignore b/src/lib/log/tests/.gitignore index e7e12d6e2f..05d0a0375d 100644 --- a/src/lib/log/tests/.gitignore +++ b/src/lib/log/tests/.gitignore @@ -15,3 +15,4 @@ /run_unittests /severity_test.sh /tempdir.h +/s-messages diff --git a/src/lib/nsas/.gitignore b/src/lib/nsas/.gitignore index 109ef0433b..691e0107e5 100644 --- a/src/lib/nsas/.gitignore +++ b/src/lib/nsas/.gitignore @@ -1,2 +1,3 @@ /nsas_messages.cc /nsas_messages.h +/s-messages diff --git a/src/lib/resolve/.gitignore b/src/lib/resolve/.gitignore index 292ed1a794..87dc694968 100644 --- a/src/lib/resolve/.gitignore +++ b/src/lib/resolve/.gitignore @@ -1,2 +1,3 @@ /resolve_messages.cc /resolve_messages.h +/s-messages diff --git a/src/lib/server_common/.gitignore b/src/lib/server_common/.gitignore index e25a98f90e..1c16f77db0 100644 --- a/src/lib/server_common/.gitignore +++ b/src/lib/server_common/.gitignore @@ -1,2 +1,3 @@ /server_common_messages.cc /server_common_messages.h +/s-messages -- cgit v1.2.3