]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Log less/better about systemd at startup
authorNick Mathewson <nickm@torproject.org>
Tue, 24 Feb 2015 16:11:24 +0000 (11:11 -0500)
committerNick Mathewson <nickm@torproject.org>
Tue, 24 Feb 2015 16:11:24 +0000 (11:11 -0500)
Report errors if the notification fails; report success only if it
succeeds; and if we are not notifying systemd because we aren't
running with systemd, don't log at notice.

src/or/main.c

index 2ef7a7482e05a28301b9204dc234b5c2fbc5caee..bc89458e871aa43a8f02796c0d20d1bfa5e6afe7 100644 (file)
@@ -2071,8 +2071,17 @@ do_main_loop(void)
 #endif
 
 #ifdef HAVE_SYSTEMD
-  log_notice(LD_GENERAL, "Signaling readiness to systemd");
-  sd_notify(0, "READY=1");
+  {
+    const int r = sd_notify(0, "READY=1");
+    if (r < 0) {
+      log_warn(LD_GENERAL, "Unable to send readiness to systemd: %s",
+               strerror(r));
+    } else if (r > 0) {
+      log_notice(LD_GENERAL, "Signaled readiness to systemd");
+    } else {
+      log_info(LD_GENERAL, "Systemd NOTIFY_SOCKET not present.");
+    }
+  }
 #endif
 
   for (;;) {