[Git][NTPsec/ntpsec][master] ntpsnmpd checks ability to connect to master before daemonizing.

Ian Bruene gitlab at mg.gitlab.com
Fri Feb 16 21:08:32 UTC 2018


Ian Bruene pushed to branch master at NTPsec / ntpsec


Commits:
cef6aa5e by Ian Bruene at 2018-02-16T15:05:59-06:00
ntpsnmpd checks ability to connect to master before daemonizing.

This makes it possible to give an error message even when daemonized.

- - - - -


1 changed file:

- ntpclients/ntpsnmpd.py


Changes:

=====================================
ntpclients/ntpsnmpd.py
=====================================
--- a/ntpclients/ntpsnmpd.py
+++ b/ntpclients/ntpsnmpd.py
@@ -1485,11 +1485,10 @@ def connect(address):
     return sock
 
 
-def mainloop(masterAddress=None, host=None):
+def mainloop(snmpSocket, host=None):
     dolog("initing loop\n", 1)
-    sock = connect(masterAddress)
     dbase = DataSource(host)
-    control = PacketControl(sock, dbase)
+    control = PacketControl(snmpSocket, dbase)
     control.loopCallback = dbase.checkNotifications
     control.initNewSession()
     control.mainloop(True)
@@ -1582,7 +1581,10 @@ if __name__ == "__main__":
 
     hostname = arguments[0] if arguments else DEFHOST
 
+    # Connect here so it can always report a connection error
+    sock = connect(masterAddr)
+
     if nofork is True:
-        mainloop(masterAddr, hostname)
+        mainloop(sock, hostname)
     else:
-        daemonize(mainloop, masterAddr, hostname)
+        daemonize(mainloop, sock, hostname)



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

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/cef6aa5ed981b75bb37323342af81039976f5ca5
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/20180216/57efbe15/attachment.html>


More information about the vc mailing list