Skip to content

Commit

Permalink
rotate: don't throw away microseconds calculating threshold
Browse files Browse the repository at this point in the history
Throwing away the microseconds from the rotation threshold doesn't affect real
world usage but it does make tests unreliable because it means the outcome is
sensitive to exactly which part of a second the test is running in and if near
the rollover point then a different result is obtained.
  • Loading branch information
andy-bower authored and thkukuk committed Feb 10, 2025
1 parent 608632a commit b585c09
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/sqlite.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,11 +526,11 @@ sqlite_rotate(const char *db_path, const int days, char **wtmpdb_name,
sqlite3 *db_src;
sqlite3 *db_dest;
uint64_t counter = 0;
struct timespec ts_now;
clock_gettime (CLOCK_REALTIME, &ts_now);
time_t offset = ts_now.tv_sec - days * 86400;
struct tm *tm = localtime (&offset);
uint64_t login_t = offset * USEC_PER_SEC;
struct timespec threshold;
clock_gettime (CLOCK_REALTIME, &threshold);
threshold.tv_sec -= days * 86400;
struct tm *tm = localtime (&threshold.tv_sec);
uint64_t login_t = wtmpdb_timespec2usec (threshold);
char date[10];
strftime (date, 10, "%Y%m%d", tm);
char *dest_path = NULL;
Expand Down

0 comments on commit b585c09

Please sign in to comment.