diff options
author | Mattias Andrée <maandree@kth.se> | 2021-02-19 15:55:08 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2021-02-19 15:55:08 +0100 |
commit | 3afa34e8db077e7d771e61f9cdc59dcd6e0a7c8a (patch) | |
tree | e95b58194bcf96009729e6484ed96b125b58c898 | |
parent | Update documentation (diff) | |
download | mongoclock-3.1.1.tar.gz mongoclock-3.1.1.tar.bz2 mongoclock-3.1.1.tar.xz |
Fix leap second support3.1.1
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | mongoclock.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/mongoclock.c b/mongoclock.c index 3823b13..dfc5578 100644 --- a/mongoclock.c +++ b/mongoclock.c @@ -135,11 +135,29 @@ display_time(int timerfd) r = adjtimex(&timex); if (r == -1) goto fail; - now = localtime(&timex.time.tv_sec); - if (now == NULL) - goto fail; - if (r == TIME_OOP) + if (timex.time.tv_sec % (24 * 60 * 60) == 0) { + if (r == TIME_INS) { + timex.time.tv_sec -= 1; + now = localtime(&timex.time.tv_sec); + if (!now) + goto fail; + now->tm_sec += 1; + goto now_checked; + } else if (r == TIME_DEL) { + timex.time.tv_sec += 1; + now = localtime(&timex.time.tv_sec); + } else { + now = localtime(&timex.time.tv_sec); + } + } else if (r == TIME_OOP) { + now = localtime(&timex.time.tv_sec); now->tm_sec += 1; + } else { + now = localtime(&timex.time.tv_sec); + } + if (!now) + goto fail; + now_checked: #else now_ = time(NULL); if (now_ == -1) |