Browse Source

[1924] (minor) More comment tweaks

Michal 'vorner' Vaner 12 years ago
parent
commit
6e489c0c04
2 changed files with 15 additions and 6 deletions
  1. 7 0
      src/bin/msgq/msgq.py.in
  2. 8 6
      src/bin/msgq/tests/msgq_test.py

+ 7 - 0
src/bin/msgq/msgq.py.in

@@ -569,6 +569,13 @@ class MsgQ:
             # (and the message isn't a reply itself). We need to send
             # (and the message isn't a reply itself). We need to send
             # an error to satisfy the senders hunger for response, since
             # an error to satisfy the senders hunger for response, since
             # nobody else will do that.
             # nobody else will do that.
+            #
+            # We omit the replies on purpose. The recipient might generate
+            # the response by copying and mangling the header of incoming
+            # message (just like we do below) and would include the want_answer
+            # by accident. And we want to avoid loops of errors. Also, it
+            # is unclear if the knowledge of undeliverable reply would be
+            # of any use to the sender, and it should be much rarer situation.
 
 
             # The real errors would be positive, 1 most probably. We use
             # The real errors would be positive, 1 most probably. We use
             # negative errors for delivery errors to distinguish them a
             # negative errors for delivery errors to distinguish them a

+ 8 - 6
src/bin/msgq/tests/msgq_test.py

@@ -166,6 +166,13 @@ class MsgQTest(unittest.TestCase):
         """
         """
         Send several packets through the MsgQ and check it generates
         Send several packets through the MsgQ and check it generates
         undeliverable notifications under the correct circumstances.
         undeliverable notifications under the correct circumstances.
+
+        The test is not exhaustive as it doesn't test all combination
+        of existence of the recipient, addressing schemes, want_answer
+        header and the reply header. It is not needed, these should
+        be mostly independant (eg. if the recipient is missing, it
+        shouldn't matter why to the handling of the reply header). If
+        we included everything, the test would have too many scenarios.
         """
         """
         sent_messages = []
         sent_messages = []
         def fake_send_prepared_msg(socket, msg):
         def fake_send_prepared_msg(socket, msg):
@@ -214,12 +221,7 @@ class MsgQTest(unittest.TestCase):
                           self.parse_msg(sent_messages[0][1]))
                           self.parse_msg(sent_messages[0][1]))
         # the reply header too.
         # the reply header too.
         sent_messages = []
         sent_messages = []
-        # If the message is a reply itself, we never generate the errors, even
+        # If the message is a reply itself, we never generate the errors
-        # if they can't be delivered. This is partly because the answer reuses
-        # 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.
         routing["reply"] = 3
         routing["reply"] = 3
         self.__msgq.process_command_send(sender, routing, data)
         self.__msgq.process_command_send(sender, routing, data)
         self.assertEqual([], sent_messages)
         self.assertEqual([], sent_messages)