Mark Bergsma has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/371102 )

Change subject: Handle failing TCP socket options in IdleConnection
......................................................................

Handle failing TCP socket options in IdleConnection

Linux socket options TCP_KEEPIDLE are not portable, fail gracefully
if they don't exist (e.g. on other platforms).

Change-Id: I79041b4baabeeb537ed9d4cb4a249f97f75a35aa
---
M pybal/monitors/idleconnection.py
1 file changed, 8 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/debs/pybal 
refs/changes/02/371102/1

diff --git a/pybal/monitors/idleconnection.py b/pybal/monitors/idleconnection.py
index fd105dd..16bde75 100644
--- a/pybal/monitors/idleconnection.py
+++ b/pybal/monitors/idleconnection.py
@@ -5,13 +5,14 @@
 Monitor class implementations for PyBal
 """
 
-from pybal import monitor
+from pybal import monitor, util
 
 from twisted.internet import reactor, protocol
 import logging
 
 import socket
 
+log = util.log
 
 class IdleConnectionMonitoringProtocol(monitor.MonitoringProtocol, 
protocol.ReconnectingClientFactory):
     """
@@ -106,9 +107,12 @@
         if self.transport is not None and self.keepAlive:
             sock = self.transport.getHandle()
             sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
-            sock.setsockopt(socket.SOL_TCP, socket.TCP_KEEPIDLE, 
self.keepAliveIdle)
-            sock.setsockopt(socket.SOL_TCP, socket.TCP_KEEPCNT, 
self.keepAliveRetries)
-            sock.setsockopt(socket.SOL_TCP, socket.TCP_KEEPINTVL, 
self.keepAliveInterval)
+            try:
+                sock.setsockopt(socket.SOL_TCP, socket.TCP_KEEPIDLE, 
self.keepAliveIdle)
+                sock.setsockopt(socket.SOL_TCP, socket.TCP_KEEPCNT, 
self.keepAliveRetries)
+                sock.setsockopt(socket.SOL_TCP, socket.TCP_KEEPINTVL, 
self.keepAliveInterval)
+            except AttributeError:
+                log.warn("Could not set TCP_KEEPIDLE, TCP_KEEPCNT, 
TCP_KEEPINTVL socket options (not Linux?)")
 
         # Set status to up
         self._resultUp()

-- 
To view, visit https://gerrit.wikimedia.org/r/371102
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I79041b4baabeeb537ed9d4cb4a249f97f75a35aa
Gerrit-PatchSet: 1
Gerrit-Project: operations/debs/pybal
Gerrit-Branch: master
Gerrit-Owner: Mark Bergsma <m...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to