Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
936d5cad
Commit
936d5cad
authored
Nov 30, 2011
by
Michal 'vorner' Vaner
Browse files
[1428] Accept sockets and keep them
parent
d6d7a352
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/bin/bind10/bind10_src.py.in
View file @
936d5cad
...
...
@@ -246,6 +246,7 @@ class BoB:
self._socket_path = None
self._tmpdir = None
self._srv_socket = None
self._unix_sockets = {}
def __propagate_component_config(self, config):
comps = dict(config)
...
...
@@ -871,6 +872,8 @@ class BoB:
Accept a socket from the unix domain socket server and put it to the
others we care about.
"""
socket = self._srv_socket.accept()
self._unix_sockets[socket.fileno()] = (socket, '')
def run(self, wakeup_fd):
"""
...
...
src/bin/bind10/tests/bind10_test.py.in
View file @
936d5cad
...
...
@@ -952,8 +952,15 @@ class SocketSrvTest(unittest.TestCase):
"""
A mock socket for the select and accept and stuff like that.
"""
def __init__(self, owner, fileno=42):
self.__owner = owner
self.__fileno = fileno
def fileno(self):
return 42
return self.__fileno
def accept(self):
return self.__class__(self.__owner, 13)
class __CCS:
"""
...
...
@@ -984,7 +991,7 @@ class SocketSrvTest(unittest.TestCase):
socket is readable.
"""
self.__boss.runnable = True
self.__boss._srv_socket = self.__FalseSocket()
self.__boss._srv_socket = self.__FalseSocket(
self
)
self.__boss._srv_accept = self.__accept
self.__boss.ccs = self.__CCS()
bind10_src.select.select = self.__select_accept
...
...
@@ -994,6 +1001,19 @@ class SocketSrvTest(unittest.TestCase):
# And the select had the right parameters
self.assertEqual(([2, 1, 42], [], [], None), self.__select_called)
def test_srv_accept(self):
"""
Test how the _srv_accept method works.
"""
self.__boss._srv_socket = self.__FalseSocket(self)
self.__boss._srv_accept()
# After we accepted, a new socket is added there
socket = self.__boss._unix_sockets[13][0]
# The socket is properly stored there
self.assertIsInstance(socket, self.__FalseSocket)
# And the buffer (yet empty) is there
self.assertEqual({13: (socket, '')}, self.__boss._unix_sockets)
if __name__ == '__main__':
# store os.environ for test_unchanged_environment
original_os_environ = copy.deepcopy(os.environ)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment