Merge "eventlet: handle system that misses TCP_KEEPIDLE"
This commit is contained in:
commit
6338e83a27
@ -1089,7 +1089,7 @@ FILE_OPTIONS = {
|
||||
deprecated_for_removal=True,
|
||||
help='Sets the value of TCP_KEEPIDLE in seconds for each '
|
||||
'server socket. Only applies if tcp_keepalive is '
|
||||
'true.'),
|
||||
'true. Ignored if system does not support it.'),
|
||||
],
|
||||
'eventlet_server_ssl': [
|
||||
cfg.BoolOpt('enable', default=False, deprecated_name='enable',
|
||||
|
@ -144,8 +144,13 @@ class Server(service.ServiceBase):
|
||||
dup_socket.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
|
||||
|
||||
if self.keepidle is not None:
|
||||
dup_socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE,
|
||||
if hasattr(socket, 'TCP_KEEPIDLE'):
|
||||
dup_socket.setsockopt(socket.IPPROTO_TCP,
|
||||
socket.TCP_KEEPIDLE,
|
||||
self.keepidle)
|
||||
else:
|
||||
LOG.warning("System does not support TCP_KEEPIDLE but "
|
||||
"tcp_keepidle has been set. Ignoring.")
|
||||
|
||||
self.greenthread = self.pool.spawn(self._run,
|
||||
self.application,
|
||||
|
@ -448,12 +448,14 @@ class ServerTest(unit.TestCase):
|
||||
server.start()
|
||||
self.addCleanup(server.stop)
|
||||
|
||||
if hasattr(socket, 'TCP_KEEPIDLE'):
|
||||
self.assertEqual(2, mock_sock_dup.setsockopt.call_count)
|
||||
|
||||
# Test the last set of call args i.e. for the keepidle
|
||||
mock_sock_dup.setsockopt.assert_called_with(socket.IPPROTO_TCP,
|
||||
socket.TCP_KEEPIDLE,
|
||||
1)
|
||||
else:
|
||||
self.assertEqual(1, mock_sock_dup.setsockopt.call_count)
|
||||
|
||||
self.assertTrue(mock_listen.called)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user