Commit 4754ad34 authored by Michael Graff's avatar Michael Graff
Browse files

fix up per review comments

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/parkinglot@548 e5f2f494-b856-4b98-b285-d166d9295462
parent f7a928e0
......@@ -34,7 +34,8 @@ class SubscriptionManager:
target = ( group, instance )
if target in self.subscriptions:
print("Appending to existing target")
self.subscriptions[target].append(socket)
if socket not in self.subscriptions[target]:
self.subscriptions[target].append(socket)
else:
print("Creating new target")
self.subscriptions[target] = [ socket ]
......@@ -78,7 +79,7 @@ class MsgQ:
process listens on. If verbose is True, then the MsgQ reports
what it is doing.
"""
self.verbose = True
self.verbose = verbose
self.c_channel_port = c_channel_port
self.poller = None
self.kqueue = None
......
......@@ -48,6 +48,8 @@ def _encode_tag(tag):
... wire_partial = Message._encode_tag('this')
"""
binary = bytes(tag, 'utf-8')
if len(binary) > 255:
raise ArgumentError("tag is too long (max 255 encoded bytes)")
return(struct.pack(">B", len(binary))) + binary
def _encode_length_and_type(data, datatype):
......@@ -87,14 +89,6 @@ def _pack_hash(item):
data = _encode_hash(item)
return (_encode_length_and_type(data, _ITEM_HASH))
def _encode_utf8(item):
"""Encode a string (utf-8). More or less identity."""
return (item)
def _encode_blob(item):
"""Encode a blob (data). More or less identity."""
return (item)
def _pack_nil():
"""Encode a nil (NULL, None) item."""
return _encode_length_and_type(None, None)
......
......@@ -28,8 +28,7 @@ class Session:
self._socket = None
self._lname = None
self._recvbuffer = bytearray()
self._recvlength = None
self._sendbuffer = bytearray()
self._recvlength = 0
self._sequence = 1
self._closed = False
......@@ -94,7 +93,7 @@ class Session:
else:
self._socket.setblocking(1)
if self._recvlength == None:
if self._recvlength == 0:
length = 4
length -= len(self._recvbuffer)
try:
......@@ -122,7 +121,7 @@ class Session:
length -= len(data)
data = self._recvbuffer
self._recvbuffer = bytearray()
self._recvlength = None
self._recvlength = 0
return (data)
def _next_sequence(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment