[Git][NTPsec/ntpsec][master] ntpsnmpd now attempts to reconnect upon connection loss.

Ian Bruene gitlab at mg.gitlab.com
Wed Feb 21 01:42:52 UTC 2018


Ian Bruene pushed to branch master at NTPsec / ntpsec


Commits:
d3156ef7 by Ian Bruene at 2018-02-20T19:42:17-06:00
ntpsnmpd now attempts to reconnect upon connection loss.

- - - - -


1 changed file:

- ntpclients/ntpsnmpd.py


Changes:

=====================================
ntpclients/ntpsnmpd.py
=====================================
--- a/ntpclients/ntpsnmpd.py
+++ b/ntpclients/ntpsnmpd.py
@@ -1050,13 +1050,16 @@ def connect(address):
     return sock
 
 
-def mainloop(snmpSocket, host=None):
+def mainloop(snmpSocket, reconnectionAddr, host=None):
     dolog("initing loop\n", 1)
     dbase = DataSource(host)
-    control = PacketControl(snmpSocket, dbase, logfp=logfp)
-    control.loopCallback = dbase.checkNotifications
-    control.initNewSession()
-    control.mainloop(True)
+    while True:  # Loop reconnection attempts
+        control = PacketControl(snmpSocket, dbase, logfp=logfp)
+        control.loopCallback = dbase.checkNotifications
+        control.initNewSession()
+        if control.mainloop(True) is False:  # disconnected
+            snmpSocket.close()
+            snmpSocket = connect(reconnectionAddr)
 
 
 def daemonize(runfunc, *runArgs):



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/d3156ef760df7036b8f9db47553cdb5f374e81e3

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/d3156ef760df7036b8f9db47553cdb5f374e81e3
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20180221/b9586a83/attachment.html>


More information about the vc mailing list