BIND 10 trac1914, updated. 8adef6491ebef3e81833f3d23b334c5b4fc1f72c [1924] Use the constants in the process_command_send

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Feb 4 16:10:02 UTC 2013


The branch, trac1914 has been updated
       via  8adef6491ebef3e81833f3d23b334c5b4fc1f72c (commit)
      from  f88b4851913521da4d54becbd90dfdcace073396 (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 8adef6491ebef3e81833f3d23b334c5b4fc1f72c
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Feb 4 17:06:22 2013 +0100

    [1924] Use the constants in the process_command_send

-----------------------------------------------------------------------

Summary of changes:
 src/bin/msgq/msgq.py.in         |   18 ++++++++++--------
 src/bin/msgq/tests/msgq_test.py |   10 +++++-----
 src/lib/util/common_defs.cc     |    4 ++++
 3 files changed, 19 insertions(+), 13 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/msgq/msgq.py.in b/src/bin/msgq/msgq.py.in
index ea2e2d7..8517877 100755
--- a/src/bin/msgq/msgq.py.in
+++ b/src/bin/msgq/msgq.py.in
@@ -33,6 +33,7 @@ import threading
 import isc.config.ccsession
 from optparse import OptionParser, OptionValueError
 import isc.util.process
+from isc.util.common_defs import *
 import isc.log
 from isc.log_messages.msgq_messages import *
 
@@ -527,14 +528,14 @@ class MsgQ:
         self.sendmsg(sock, { "type" : "getlname" }, { "lname" : lname })
 
     def process_command_send(self, sock, routing, data):
-        group = routing["group"]
-        instance = routing["instance"]
-        to = routing["to"]
+        group = routing[CC_HEADER_GROUP]
+        instance = routing[CC_HEADER_INSTANCE]
+        to = routing[CC_HEADER_TO]
         if group == None or instance == None:
             # FIXME: Should we log them instead?
             return  # ignore invalid packets entirely
 
-        if to == "*":
+        if to == CC_TO_WILDCARD:
             sockets = self.subs.find(group, instance)
         else:
             if to in self.lnames:
@@ -551,7 +552,8 @@ class MsgQ:
         if sockets:
             for socket in sockets:
                 self.send_prepared_msg(socket, msg)
-        elif routing.get("wants_reply") and "reply" not in routing:
+        elif routing.get(CC_HEADER_WANT_ANSWER) and \
+            CC_HEADER_REPLY not in routing:
             # We have no recipients. But the sender insists on a reply
             # (and the message isn't a reply itself). We need to send
             # an error to satisfy the senders hurger for response, since
@@ -567,9 +569,9 @@ class MsgQ:
             # want to mangle it for the caller, so we get a copy. A shallow
             # one should be enough, we modify the dict only.
             header = routing.copy()
-            header["reply"] = routing["seq"]
-            header["from"] = 'msgq' # Dummy lname not assigned to clients
-            header["to"] = routing["from"]
+            header[CC_HEADER_REPLY] = routing[CC_HEADER_SEQ]
+            header[CC_HEADER_FROM] = "msgq" # Dummy lname not assigned to clients
+            header[CC_HEADER_TO] = routing[CC_HEADER_FROM]
             # We keep the seq as it is. We don't need to track the message
             # and provided the sender always uses a new one, it won't know
             # we're cheating, since we won't send it two same either.
diff --git a/src/bin/msgq/tests/msgq_test.py b/src/bin/msgq/tests/msgq_test.py
index 1748c17..f3ffcf9 100644
--- a/src/bin/msgq/tests/msgq_test.py
+++ b/src/bin/msgq/tests/msgq_test.py
@@ -192,11 +192,11 @@ class MsgQTest(unittest.TestCase):
         self.__msgq.process_command_send(sender, routing, data)
         self.assertEqual([], sent_messages)
         # It should act the same if we explicitly say we do not want replies.
-        routing["wants_reply"] = False
+        routing["want_answer"] = False
         self.__msgq.process_command_send(sender, routing, data)
         self.assertEqual([], sent_messages)
         # Ask for errors if it can't be delivered.
-        routing["wants_reply"] = True
+        routing["want_answer"] = True
         self.__msgq.process_command_send(sender, routing, data)
         self.assertEqual(1, len(sent_messages))
         self.assertEqual(1, sent_messages[0][0])
@@ -207,14 +207,14 @@ class MsgQTest(unittest.TestCase):
                               'seq': 42,
                               'from': 'msgq',
                               'to': 'sender',
-                              'wants_reply': True
+                              'want_answer': True
                           }, {'result': [-1, "No such recipient"]}),
                           self.parse_msg(sent_messages[0][1]))
         # the reply header too.
         sent_messages = []
         # If the message is a reply itself, we never generate the errors, even
         # if they can't be delivered. This is partly because the answer reuses
-        # the old header (which would then inherit the wants_reply flag) and
+        # the old header (which would then inherit the want_answer flag) and
         # partly we want to avoid loops of errors that can't be delivered.
         # If a reply can't be delivered, the sender can't do much anyway even
         # if notified.
@@ -243,7 +243,7 @@ class MsgQTest(unittest.TestCase):
                               'seq': 42,
                               'from': 'msgq',
                               'to': 'sender',
-                              'wants_reply': True
+                              'want_answer': True
                           }, {'result': [-1, "No such recipient"]}),
                           self.parse_msg(sent_messages[0][1]))
         sent_messages = []
diff --git a/src/lib/util/common_defs.cc b/src/lib/util/common_defs.cc
index 3e9b16f..b8f9529 100644
--- a/src/lib/util/common_defs.cc
+++ b/src/lib/util/common_defs.cc
@@ -31,8 +31,12 @@ const char* CC_HEADER_GROUP = "group";
 const char* CC_HEADER_INSTANCE = "instance";
 const char* CC_HEADER_SEQ = "seq";
 const char* CC_HEADER_WANT_ANSWER = "want_answer";
+const char* CC_HEADER_REPLY = "reply";
 // The commands in the "type" header
 const char* CC_COMMAND_SEND = "send";
+// The wildcards of some headers
+const char* CC_TO_WILDCARD = "*";
+const char* CC_INSTANCE_WILDCARD = "*";
 
 }
 }



More information about the bind10-changes mailing list