BIND 10 trac2922, updated. 6ebe6bc5875d21ad1d822c251462cebe3e769aee [2922] Send notifications on implicit unsubscribe
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri May 31 10:48:20 UTC 2013
The branch, trac2922 has been updated
via 6ebe6bc5875d21ad1d822c251462cebe3e769aee (commit)
via 6bcd96718c01bdbe0d563f6c67c46b441147ba60 (commit)
from c1d7e3f9bfa473478a1070467bf0773f02e54b6e (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 6ebe6bc5875d21ad1d822c251462cebe3e769aee
Author: Michal 'vorner' Vaner <vorner at vorner.cz>
Date: Fri May 31 12:47:18 2013 +0200
[2922] Send notifications on implicit unsubscribe
commit 6bcd96718c01bdbe0d563f6c67c46b441147ba60
Author: Michal 'vorner' Vaner <vorner at vorner.cz>
Date: Fri May 31 10:57:17 2013 +0200
[2922] Return unsubscribed groups from unsubscribe_all
Return a list of groups and instances the socket was unsubscribed from
from the subscription manager's unsubscribe_all.
Needed in follow-up work.
-----------------------------------------------------------------------
Summary of changes:
src/bin/msgq/msgq.py.in | 14 ++++++++++++--
src/bin/msgq/tests/msgq_test.py | 4 +++-
2 files changed, 15 insertions(+), 3 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/msgq/msgq.py.in b/src/bin/msgq/msgq.py.in
index 3f91c90..cba8546 100755
--- a/src/bin/msgq/msgq.py.in
+++ b/src/bin/msgq/msgq.py.in
@@ -125,9 +125,12 @@ class SubscriptionManager:
def unsubscribe_all(self, socket):
"""Remove the socket from all subscriptions."""
- for socklist in self.subscriptions.values():
+ removed_from = []
+ for subs, socklist in self.subscriptions.items():
if socket in socklist:
socklist.remove(socket)
+ removed_from.append(subs)
+ return removed_from
def find_sub(self, group, instance):
"""Return an array of sockets which want this specific group,
@@ -371,7 +374,7 @@ class MsgQ:
if self.poller:
self.poller.unregister(sock)
- self.subs.unsubscribe_all(sock)
+ unsubscribed_from = self.subs.unsubscribe_all(sock)
lname = self.fd_to_lname[fd]
del self.fd_to_lname[fd]
del self.lnames[lname]
@@ -380,6 +383,13 @@ class MsgQ:
if fd in self.sendbuffs:
del self.sendbuffs[fd]
logger.debug(TRACE_BASIC, MSGQ_SOCK_CLOSE, fd)
+ # Filter out just the groups.
+ unsubscribed_from_groups = set(map(lambda x: x[0], unsubscribed_from))
+ for group in unsubscribed_from_groups:
+ self.members_notify('unsubscribed', {
+ 'client': lname,
+ 'group': group
+ })
self.members_notify('disconnected', {'client': lname})
def __getbytes(self, fd, sock, length, continued):
diff --git a/src/bin/msgq/tests/msgq_test.py b/src/bin/msgq/tests/msgq_test.py
index b01e2d4..a663843 100644
--- a/src/bin/msgq/tests/msgq_test.py
+++ b/src/bin/msgq/tests/msgq_test.py
@@ -75,7 +75,9 @@ class TestSubscriptionManager(unittest.TestCase):
self.sm.subscribe('g2', 'i1', 's2')
self.sm.subscribe('g2', 'i2', 's1')
self.sm.subscribe('g2', 'i2', 's2')
- self.sm.unsubscribe_all('s1')
+ self.assertEqual(set([('g1', 'i1'), ('g1', 'i2'), ('g2', 'i1'),
+ ('g2', 'i2')]),
+ set(self.sm.unsubscribe_all('s1')))
self.assertEqual(self.sm.find_sub("g1", "i1"), [ 's2' ])
self.assertEqual(self.sm.find_sub("g1", "i2"), [ 's2' ])
self.assertEqual(self.sm.find_sub("g2", "i1"), [ 's2' ])
More information about the bind10-changes
mailing list