BIND 10 trac2922, updated. 9d30cc97c91754a94f15ae288220401fb11cfc06 [2922] Unsubscribe from group not subscribed to
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Jun 11 10:19:04 UTC 2013
The branch, trac2922 has been updated
via 9d30cc97c91754a94f15ae288220401fb11cfc06 (commit)
from 15810521bfeea89e77334df66512863911a4d03c (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 9d30cc97c91754a94f15ae288220401fb11cfc06
Author: Michal 'vorner' Vaner <vorner at vorner.cz>
Date: Tue Jun 11 12:16:32 2013 +0200
[2922] Unsubscribe from group not subscribed to
Make sure msgq does not send notification when a client tries to
unsubscribe from a group it did not subscribe to.
-----------------------------------------------------------------------
Summary of changes:
src/bin/msgq/msgq.py.in | 16 +++++++++-------
src/bin/msgq/tests/msgq_test.py | 10 +++++++++-
2 files changed, 18 insertions(+), 8 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/msgq/msgq.py.in b/src/bin/msgq/msgq.py.in
index 135ae8a..7aee470 100755
--- a/src/bin/msgq/msgq.py.in
+++ b/src/bin/msgq/msgq.py.in
@@ -124,6 +124,8 @@ class SubscriptionManager:
if target in self.subscriptions:
if socket in self.subscriptions[target]:
self.subscriptions[target].remove(socket)
+ return True
+ return False
def unsubscribe_all(self, socket):
"""Remove the socket from all subscriptions."""
@@ -703,13 +705,13 @@ class MsgQ:
instance = routing[CC_HEADER_INSTANCE]
if group == None or instance == None:
return # ignore invalid packets entirely
- self.subs.unsubscribe(group, instance, sock)
- lname = self.fd_to_lname[sock.fileno()]
- self.members_notify('unsubscribed',
- {
- 'client': lname,
- 'group': group
- })
+ if self.subs.unsubscribe(group, instance, sock):
+ lname = self.fd_to_lname[sock.fileno()]
+ self.members_notify('unsubscribed',
+ {
+ 'client': lname,
+ 'group': group
+ })
def run(self):
"""Process messages. Forever. Mostly."""
diff --git a/src/bin/msgq/tests/msgq_test.py b/src/bin/msgq/tests/msgq_test.py
index 1b569cb..ffe1940 100644
--- a/src/bin/msgq/tests/msgq_test.py
+++ b/src/bin/msgq/tests/msgq_test.py
@@ -63,7 +63,9 @@ class TestSubscriptionManager(unittest.TestCase):
socks = [ 's1', 's2', 's3', 's4', 's5' ]
for s in socks:
self.sm.subscribe("a", "*", s)
- self.sm.unsubscribe("a", "*", 's3')
+ self.assertTrue(self.sm.unsubscribe("a", "*", 's3'))
+ # Unsubscribe from group it is not in
+ self.assertFalse(self.sm.unsubscribe("a", "*", 's42'))
self.assertEqual(self.sm.find_sub("a", "*"),
[ 's1', 's2', 's4', 's5' ])
@@ -300,6 +302,12 @@ class MsgQTest(unittest.TestCase):
notifications)
notifications.clear()
+ # Unsubscription from a group it isn't subscribed to
+ self.__msgq.process_command_unsubscribe(sock, {'group': 'H',
+ 'instance': '*'},
+ None)
+ self.assertEqual([], notifications)
+
# And, finally, for removal of client
self.__msgq.kill_socket(sock.fileno(), sock)
self.assertEqual([('disconnected', {'client': lname})], notifications)
More information about the bind10-changes
mailing list