summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2020-02-03 17:33:59 +0000
committerGerrit Code Review <review@openstack.org>2020-02-03 17:33:59 +0000
commit4fbb6d1a57de3ad1e6cb5207c2f4e09be9580a7a (patch)
tree358f820610c13ae813c837b3c938c8bee10b7c19
parent4243fc031b7ed607c6018c957d6e86a547f147c6 (diff)
parentc9f23749c6f4ae6933fbd800dace776fbb1362a0 (diff)
downloadgear-4fbb6d1a57de3ad1e6cb5207c2f4e09be9580a7a.tar.gz
Merge "Ignore keepalive on unsupported platforms"0.15.0
-rw-r--r--gear/__init__.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/gear/__init__.py b/gear/__init__.py
index 38b037a..55f804f 100644
--- a/gear/__init__.py
+++ b/gear/__init__.py
@@ -191,7 +191,7 @@ class Connection(object):
af, socktype, proto, canonname, sa = res
try:
s = socket.socket(af, socktype, proto)
- if self.keepalive:
+ if self.keepalive and hasattr(socket, 'TCP_KEEPIDLE'):
s.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
s.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE,
self.tcp_keepidle)
@@ -199,6 +199,9 @@ class Connection(object):
self.tcp_keepintvl)
s.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPCNT,
self.tcp_keepcnt)
+ elif self.keepalive:
+ self.log.warning('Keepalive requested but not available '
+ 'on this platform')
except socket.error:
s = None
continue
@@ -2810,7 +2813,7 @@ class Server(BaseClientServer):
self.socket = socket.socket(af, socktype, proto)
self.socket.setsockopt(socket.SOL_SOCKET,
socket.SO_REUSEADDR, 1)
- if keepalive:
+ if keepalive and hasattr(socket, 'TCP_KEEPIDLE'):
self.socket.setsockopt(socket.SOL_SOCKET,
socket.SO_KEEPALIVE, 1)
self.socket.setsockopt(socket.IPPROTO_TCP,
@@ -2819,6 +2822,9 @@ class Server(BaseClientServer):
socket.TCP_KEEPINTVL, tcp_keepintvl)
self.socket.setsockopt(socket.IPPROTO_TCP,
socket.TCP_KEEPCNT, tcp_keepcnt)
+ elif keepalive:
+ self.log.warning('Keepalive requested but not available '
+ 'on this platform')
except socket.error:
self.socket = None
continue