Only set TCP_KEEPIDLE where supported

Resolves an issue preventing Swift from starting on BSD-based platforms
that do not have this TCP flag (FreeBSD, OSX/Darwin, OpenBSD); identical
to Glance bug 879195, change I2f062a34, Glance commit efcdac36
(originally reported and patched by Brian Waldon).

Change-Id: Ifd696fe1080464d060e608c075ad0c113baab5ab
This commit is contained in:
Brian Cline 2012-09-21 11:05:11 -05:00
parent 8a7afa535f
commit da99c3390b
1 changed files with 2 additions and 1 deletions

View File

@ -90,7 +90,8 @@ def get_socket(conf, default_port=8080):
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
# in my experience, sockets can hang around forever without keepalive
sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, 600)
if hasattr(socket, 'TCP_KEEPIDLE'):
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, 600)
if warn_ssl:
ssl_warning_message = 'WARNING: SSL should only be enabled for ' \
'testing purposes. Use external SSL ' \