BIND 10 trac1914, updated. 3e94ba20d52e2c62243af504f95f5b3134efd0f7 [1924] Send the errors about missing recipient

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Jan 30 10:19:17 UTC 2013


The branch, trac1914 has been updated
       via  3e94ba20d52e2c62243af504f95f5b3134efd0f7 (commit)
      from  86a88ca3f958089b8d586d77f0e501f2792320d3 (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 3e94ba20d52e2c62243af504f95f5b3134efd0f7
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Wed Jan 30 11:17:27 2013 +0100

    [1924] Send the errors about missing recipient
    
    If the msgq finds no recipient to send to and the sender wants an
    answer, provide an error as the answer. Also check the error messages
    look sane in tests.

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

Summary of changes:
 src/bin/msgq/msgq.py.in         |   30 +++++++++++++++++++++++++++---
 src/bin/msgq/tests/msgq_test.py |   23 +++++++++++++++++++++--
 2 files changed, 48 insertions(+), 5 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/msgq/msgq.py.in b/src/bin/msgq/msgq.py.in
index ab40183..f3b2777 100755
--- a/src/bin/msgq/msgq.py.in
+++ b/src/bin/msgq/msgq.py.in
@@ -548,9 +548,33 @@ class MsgQ:
             # Don't bounce to self
             sockets.remove(sock)
 
-        # TODO: The place to create an undeliverable error, if requested
-        for socket in sockets:
-            self.send_prepared_msg(socket, msg)
+        if sockets:
+            for socket in sockets:
+                self.send_prepared_msg(socket, msg)
+        elif routing.get("wants_reply") and "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
+            # nobody else will do that.
+
+            # The real errors would be positive, 1 most probably. We use
+            # negative errors for delivery errors to distinguish them a
+            # little. We probably should have a way to provide more data
+            # in the error message.
+            payload = isc.config.ccsession.create_answer(-1,
+                                                         "No such recipient")
+            # We create the header based on the current one. But we don't
+            # 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"]
+            # The other headers can just stay the same. They are not used
+            # in the recipient and we know where to send it, so we don't
+            # need the "to" header. We don't know the sender's lname
+            # in this part of code anyway.
+            errmsg = self.preparemsg(header, payload)
+            # Send it back.
+            self.send_prepared_msg(sock, errmsg)
 
     def process_command_subscribe(self, sock, routing, data):
         group = routing["group"]
diff --git a/src/bin/msgq/tests/msgq_test.py b/src/bin/msgq/tests/msgq_test.py
index c5e0551..d3c430a 100644
--- a/src/bin/msgq/tests/msgq_test.py
+++ b/src/bin/msgq/tests/msgq_test.py
@@ -194,7 +194,16 @@ class MsgQTest(unittest.TestCase):
         routing["wants_reply"] = True
         self.__msgq.process_command_send(sender, routing, data)
         self.assertEqual(1, len(sent_messages))
-        # TODO: Parse the message and check it looks correct. It should contain
+        self.assertEqual(1, sent_messages[0][0])
+        self.assertEqual(({
+                              'group': 'group',
+                              'instance': '*',
+                              'reply': 42,
+                              'seq': 42,
+                              'to': '*',
+                              'wants_reply': 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
@@ -220,7 +229,17 @@ class MsgQTest(unittest.TestCase):
         routing["to"] = "lname"
         self.__msgq.process_command_send(sender, routing, data)
         self.assertEqual(1, len(sent_messages))
-        # TODO: Parse the errors
+        self.assertEqual(1, sent_messages[0][0])
+        self.assertEqual(({
+                              'group': 'group',
+                              'instance': '*',
+                              'reply': 42,
+                              'seq': 42,
+                              'to': 'lname',
+                              'wants_reply': True
+                          }, {'result': [-1, "No such recipient"]}),
+                          self.parse_msg(sent_messages[0][1]))
+        sent_messages = []
         # But when the recipient is there, it is delivered and no error is
         # generated.
         self.__msgq.lnames["lname"] = recipient



More information about the bind10-changes mailing list