mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 16:35:06 -05:00
Fix writing of drift and RTC files
Without sequence points the driftfile and RTC file could be closed before new values were written.
This commit is contained in:
@@ -467,6 +467,7 @@ write_coefs_to_file(int valid,time_t ref_time,double offset,double rate)
|
||||
struct stat buf;
|
||||
char *temp_coefs_file_name;
|
||||
FILE *out;
|
||||
int r1, r2;
|
||||
|
||||
/* Create a temporary file with a '.tmp' extension. */
|
||||
|
||||
@@ -488,9 +489,10 @@ write_coefs_to_file(int valid,time_t ref_time,double offset,double rate)
|
||||
}
|
||||
|
||||
/* Gain rate is written out in ppm */
|
||||
if ((fprintf(out, "%1d %ld %.6f %.3f\n",
|
||||
valid,ref_time, offset, 1.0e6 * rate) < 0) |
|
||||
fclose(out)) {
|
||||
r1 = fprintf(out, "%1d %ld %.6f %.3f\n",
|
||||
valid, ref_time, offset, 1.0e6 * rate);
|
||||
r2 = fclose(out);
|
||||
if (r1 < 0 || r2) {
|
||||
Free(temp_coefs_file_name);
|
||||
LOG(LOGS_WARN, LOGF_RtcLinux, "Could not write to temporary RTC file %s.tmp",
|
||||
coefs_file_name);
|
||||
|
||||
Reference in New Issue
Block a user