diff --git a/sys_linux.c b/sys_linux.c index e5ca9a6..fc0249a 100644 --- a/sys_linux.c +++ b/sys_linux.c @@ -177,9 +177,9 @@ read_frequency(void) static void set_leap(int leap) { - int current_leap; + int current_leap, applied; - if (TMX_GetLeap(¤t_leap) < 0) { + if (TMX_GetLeap(¤t_leap, &applied) < 0) { LOG_FATAL(LOGF_SysLinux, "adjtimex() failed in set_leap"); } @@ -190,8 +190,9 @@ set_leap(int leap) LOG_FATAL(LOGF_SysLinux, "adjtimex() failed in set_leap"); } - LOG(LOGS_INFO, LOGF_SysLinux, "System clock status set to %s leap second", - leap ? (leap > 0 ? "insert" : "delete") : "not insert/delete"); + LOG(LOGS_INFO, LOGF_SysLinux, "System clock status %s leap second", + leap ? (leap > 0 ? "set to insert" : "set to delete") : + (applied ? "reset after" : "set to not insert/delete")); } /* ================================================== */ diff --git a/wrap_adjtimex.c b/wrap_adjtimex.c index 50c4ab7..ce6f267 100644 --- a/wrap_adjtimex.c +++ b/wrap_adjtimex.c @@ -124,24 +124,25 @@ TMX_SetLeap(int leap) } int -TMX_GetLeap(int *leap) +TMX_GetLeap(int *leap, int *applied) { struct timex txc; + int state; txc.modes = 0; - if (adjtimex(&txc) < 0) + state = adjtimex(&txc); + if (state < 0) return -1; - status &= ~(STA_INS | STA_DEL); - status |= txc.status & (STA_INS | STA_DEL); - - if (status & STA_INS) + if (txc.status & STA_INS) *leap = 1; - else if (status & STA_DEL) + else if (txc.status & STA_DEL) *leap = -1; else *leap = 0; + *applied = state == TIME_WAIT; + return 0; } diff --git a/wrap_adjtimex.h b/wrap_adjtimex.h index 23587a3..217d060 100644 --- a/wrap_adjtimex.h +++ b/wrap_adjtimex.h @@ -31,7 +31,7 @@ int TMX_ResetOffset(void); int TMX_SetFrequency(double *freq, long tick); int TMX_GetFrequency(double *freq, long *tick); int TMX_SetLeap(int leap); -int TMX_GetLeap(int *leap); +int TMX_GetLeap(int *leap, int *applied); int TMX_SetSync(int sync, double est_error, double max_error); int TMX_TestStepOffset(void); int TMX_ApplyStepOffset(double offset);