Commit 619dbae4 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[805] Data sent/received are bytes, not str

parent 3cdb0087
......@@ -85,8 +85,8 @@ DBG_PROCESS = logger.DBGLVL_TRACE_BASIC
DBG_COMMANDS = logger.DBGLVL_TRACE_DETAIL
# Messages sent over the unix domain socket to indicate if it is followed by a real socket
CREATOR_SOCKET_OK = "1\n"
CREATOR_SOCKET_UNAVAILABLE = "0\n"
CREATOR_SOCKET_OK = b"1\n"
CREATOR_SOCKET_UNAVAILABLE = b"0\n"
# Assign this process some longer name
isc.util.process.rename(sys.argv[0])
......@@ -836,6 +836,7 @@ class BoB:
identified by the token back over the unix_socket.
"""
try:
token = str(token, 'ASCII') # Convert from bytes to str
fd = self._socket_cache.get_socket(token, unix_socket.fileno())
# FIXME: These two calls are blocking in their nature. An OS-level
# buffer is likely to be large enough to hold all these data, but
......
......@@ -146,7 +146,7 @@ class TestCacheCommands(unittest.TestCase):
socket.
"""
def __init__(self):
self.send = ""
self.send = b""
def fileno(self):
"""
The file number. Used for identifying the remote application.
......@@ -207,17 +207,17 @@ class TestCacheCommands(unittest.TestCase):
socket = self.FalseSocket()
# An exception from the cache
self.__raise_exception = ValueError("Test value error")
self.__boss.socket_request_handler("token", socket)
self.__boss.socket_request_handler(b"token", socket)
# It was called, but it threw, so it is not noted here
self.assertIsNone(self.__get_socket_called)
self.assertEqual("0\n", socket.send)
self.assertEqual(b"0\n", socket.send)
# It should not have sent any socket.
self.assertIsNone(self.__send_fd_called)
# Now prepare a valid scenario
self.__raise_exception = None
socket.send = ""
self.__boss.socket_request_handler("token", socket)
self.assertEqual("1\n", socket.send)
socket.send = b""
self.__boss.socket_request_handler(b"token", socket)
self.assertEqual(b"1\n", socket.send)
self.assertEqual((42, 13), self.__send_fd_called)
self.assertEqual(("token", 42), self.__get_socket_called)
......
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