]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
reference: exit with non-zero code when maxchange limit is reached
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 7 Apr 2014 16:26:16 +0000 (18:26 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 9 Apr 2014 07:59:58 +0000 (09:59 +0200)
Use ending of normal mode to signal a failure.

main.c
reference.c

diff --git a/main.c b/main.c
index 7eaf63ac4ae5fbcef69cd35378b2435982f820c5..5ed3addafdeb03ea71b20d2c9a64b9f57385b9db 100644 (file)
--- a/main.c
+++ b/main.c
@@ -59,7 +59,7 @@
 
 static int initialised = 0;
 
-/* ================================================== */
+static int exit_status = 0;
 
 static int reload = 0;
 
@@ -80,7 +80,7 @@ delete_pidfile(void)
 void
 MAI_CleanupAndExit(void)
 {
-  if (!initialised) exit(0);
+  if (!initialised) exit(exit_status);
   
   if (CNF_GetDumpOnExit()) {
     SRC_DumpSources();
@@ -108,7 +108,7 @@ MAI_CleanupAndExit(void)
   
   LOG_Finalise();
 
-  exit(0);
+  exit(exit_status);
 }
 
 /* ================================================== */
@@ -157,6 +157,8 @@ reference_mode_end(int result)
 {
   switch (ref_mode) {
     case REF_ModeNormal:
+      exit_status = !result;
+      SCH_QuitProgram();
       break;
     case REF_ModeInitStepSlew:
       /* post_init_ntp_hook removes sources and a source call is
index 3a721b96bcffa7c5545ecd49f26663c8cd4c4cbf..f757f173c80acc506fab4cfe232c17f3618ca292 100644 (file)
@@ -580,7 +580,7 @@ is_offset_ok(double offset)
         "Adjustment of %.3f seconds exceeds the allowed maximum of %.3f seconds (%s) ",
         offset, max_offset, !max_offset_ignore ? "exiting" : "ignored");
     if (!max_offset_ignore)
-      SCH_QuitProgram();
+      end_ref_mode(0);
     else if (max_offset_ignore > 0)
       max_offset_ignore--;
     return 0;