]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 808] Only write the drift file if we are in state 4
authorHarlan Stenn <stenn@ntp.org>
Mon, 21 May 2007 04:29:26 +0000 (00:29 -0400)
committerHarlan Stenn <stenn@ntp.org>
Mon, 21 May 2007 04:29:26 +0000 (00:29 -0400)
bk: 46512026ogiF0i6ITK52B_tfI82IOg

ChangeLog
ntpd/ntp_util.c

index 69a3e885ad91e9fe6c8380dc291af025a182d437..8b4f9ea350a7f87733b0f156ffd35b477870828b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+* [Bug 808] Only write the drift file if we are in state 4.
 * Initial import of libisc/log.c and friends.
 * [Bug 826] Fix redefinition of PI.
 * [Bug 825] ntp_scanner.c needs to #include <config.h> .
index 1934a5c6bf948f8b2353a0d1c1dd8f4d01f92969..6c2fdce4d9a569fd899f83b08718602271f68f08 100644 (file)
@@ -221,40 +221,43 @@ write_stats(void)
        }
        prev_drift_comp = drift_comp;
        if (stats_drift_file != 0) {
-               if ((fp = fopen(stats_temp_file, "w")) == NULL) {
-                       msyslog(LOG_ERR, "can't open %s: %m",
-                           stats_temp_file);
-                       return;
-               }
-               fprintf(fp, "%.3f\n", drift_comp * 1e6);
-               (void)fclose(fp);
-               /* atomic */
+               if (state == 4) {
+                       if ((fp = fopen(stats_temp_file, "w")) == NULL) {
+                               msyslog(LOG_ERR, "can't open %s: %m",
+                                       stats_temp_file);
+                               return;
+                       }
+                       fprintf(fp, "%.3f\n", drift_comp * 1e6);
+                       (void)fclose(fp);
+                       /* atomic */
 #ifdef SYS_WINNT
-               (void) _unlink(stats_drift_file); /* rename semantics differ under NT */
+                       (void) _unlink(stats_drift_file); /* rename semantics differ under NT */
 #endif /* SYS_WINNT */
 
 #ifndef NO_RENAME
-               (void) rename(stats_temp_file, stats_drift_file);
+                       (void) rename(stats_temp_file, stats_drift_file);
 #else
-               /* we have no rename NFS of ftp in use */
-               if ((fp = fopen(stats_drift_file, "w")) == NULL) {
-                       msyslog(LOG_ERR, "can't open %s: %m",
-                           stats_drift_file);
-                       return;
-               }
-
+                       /* we have no rename NFS of ftp in use */
+                       if ((fp = fopen(stats_drift_file, "w")) == NULL) {
+                               msyslog(LOG_ERR, "can't open %s: %m",
+                                       stats_drift_file);
+                               return;
+                       }
 #endif
 
 #if defined(VMS)
-               /* PURGE */
-               {
-                       $DESCRIPTOR(oldvers,";-1");
-                       struct dsc$descriptor driftdsc = {
-                               strlen(stats_drift_file),0,0,stats_drift_file };
+                       /* PURGE */
+                       {
+                               $DESCRIPTOR(oldvers,";-1");
+                               struct dsc$descriptor driftdsc = {
+                                       strlen(stats_drift_file),0,0,stats_drift_file };
 
-                       while(lib$delete_file(&oldvers,&driftdsc) & 1) ;
-               }
+                               while(lib$delete_file(&oldvers,&driftdsc) & 1);
+                       }
 #endif
+               } else {
+                       /* XXX: Log a message at INFO level */
+               }
        }
 }