Commit b6aa3ff5 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[1454] Call handle_incoming when there's data

parent 9af13dfc
......@@ -138,6 +138,12 @@ class DDNSServer:
session = isc.util.io.socketsession.SocketSessionReceiver(socket)
self._socket_sessions[fileno] = (socket, session)
def handle_incoming(self, fileno):
"""
Handle incoming event on the socket with given fileno.
"""
pass
def run(self):
'''
Get and process all commands sent from cfgmgr or other modules.
......@@ -155,14 +161,15 @@ class DDNSServer:
# TODO: Catch select exceptions, like EINTR
(reads, writes, exceptions) = \
select.select([cc_fileno, listen_fileno], [], [])
select.select([cc_fileno, listen_fileno] +
list(self._socket_sessions.keys()), [], [])
for fileno in reads:
if fileno == cc_fileno:
self._cc.check_command(True)
elif fileno == listen_fileno:
self.accept()
else:
pass # TODO
self.handle_incoming(fileno)
self.shutdown_cleanup()
logger.info(DDNS_STOPPED)
......
......@@ -202,6 +202,21 @@ class TestDDNSServer(unittest.TestCase):
self.assertTrue(isinstance(session, FakeSession))
self.assertEqual(socket, session.socket())
def test_incoming_called(self):
"""
Test the run calls handle_incoming when there's something on the
socket.
"""
socket = FakeSocket(3)
self.ddns_server._socket_sessions = {3: (socket, FakeSession(socket))}
self.ddns_server.handle_incoming = self.__hook
self.__select_expected = ([1, 2, 3], [], [], None)
self.__select_answer = ([3], [], [])
self.ddns_server.run()
self.assertTrue(self.ddns_server._shutdown)
self.assertIsNone(self.__select_answer)
self.assertEqual(3, self.__hook_called)
class TestMain(unittest.TestCase):
def setUp(self):
self._server = MyDDNSServer()
......
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