Giuseppe Lavagetto has submitted this change and it was merged.

Change subject: Make all IdleConnection TCP KeepAlive parameters configurable
......................................................................


Make all IdleConnection TCP KeepAlive parameters configurable

This commit creates several configuration options for TCP KeepAlive
in IdleConnection, instead of using the hardcoded values. The default
values have also been changed to be slightly less aggressive.

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

Approvals:
  Giuseppe Lavagetto: Verified; Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pybal/monitors/idleconnection.py b/pybal/monitors/idleconnection.py
index 5ac7ea0..1c34634 100644
--- a/pybal/monitors/idleconnection.py
+++ b/pybal/monitors/idleconnection.py
@@ -25,7 +25,10 @@
 
     TIMEOUT_CLEAN_RECONNECT = 3
     MAX_DELAY = 300
-    KEEPALIVE_RETRIES = 10
+    KEEPALIVE = True
+    KEEPALIVE_RETRIES = 3
+    KEEPALIVE_IDLE = 10
+    KEEPALIVE_INTERVAL = 30
 
     __name__ = 'IdleConnection'
 
@@ -37,8 +40,10 @@
 
         self.toCleanReconnect = self._getConfigInt('timeout-clean-reconnect', 
self.TIMEOUT_CLEAN_RECONNECT)
         self.maxDelay = self._getConfigInt('max-delay', self.MAX_DELAY)
-        self.keepAliveRetries = self._getConfigInt('keepalive-retries',
-                                                   self.KEEPALIVE_RETRIES)
+        self.keepAlive = self._getConfigBool('keepalive', self.KEEPALIVE)
+        self.keepAliveRetries = self._getConfigInt('keepalive-retries', 
self.KEEPALIVE_RETRIES)
+        self.keepAliveIdle = self._getConfigInt('keepalive-idle', 
self.KEEPALIVE_IDLE)
+        self.keepAliveInterval = self._getConfigInt('keepalive-interval', 
self.KEEPALIVE_INTERVAL)
 
     def run(self):
         """Start the monitoring"""
@@ -96,13 +101,12 @@
         if not self.active:
             return
 
-        if self.transport is not None:
+        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, 1)
-            sock.setsockopt(socket.SOL_TCP, socket.TCP_KEEPCNT,
-                            self.keepAliveRetries)
-            sock.setsockopt(socket.SOL_TCP, socket.TCP_KEEPINTVL, 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)
 
         # Set status to up
         self._resultUp()

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1f5e0993f1901def199e0fb4d3790836dc7db2f2
Gerrit-PatchSet: 1
Gerrit-Project: operations/debs/pybal
Gerrit-Branch: master
Gerrit-Owner: Mark Bergsma <[email protected]>
Gerrit-Reviewer: BBlack <[email protected]>
Gerrit-Reviewer: Faidon Liambotis <[email protected]>
Gerrit-Reviewer: Giuseppe Lavagetto <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to