Re: [chrony-dev] [PATCH 1/1] reference: support leap-seconds.list leap second source |
[ Thread Index |
Date Index
| More chrony.tuxfamily.org/chrony-dev Archives
]
- To: chrony-dev@xxxxxxxxxxxxxxxxxxxx
- Subject: Re: [chrony-dev] [PATCH 1/1] reference: support leap-seconds.list leap second source
- From: Patrick Oppenlander <patrick.oppenlander@xxxxxxxxx>
- Date: Thu, 30 Nov 2023 09:25:09 +1100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701296720; x=1701901520; darn=chrony.tuxfamily.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=d7uR1jIGu3zLW9ay7UxnmEbAZOdM61Kta9c69azhkUs=; b=QE1R+gbHbn3OxtZaemAwiZvdykpLatGJ6DbBXPKRTfsCVFgrP37fZV+WjlVv6K4O2L 3T+YphWoEeLTMc46IzHBDDADG4rTCiL83tHvO0GGBLGDo/tlsDek4sw/1emrNZN4nUwk grX7G/zQZEhXmMfNDwqRf2jTB3kEPbYgHAMrAGfngzBEJYlf7V8EJ2Av0P2yQzkxMqrW ZlLhNQaGKcCLmDDQoUM0gUlnDpmoPFNYGdNiSwqfi2mgSbPhQRSBC2gQvJFP1axlW9rj fQx8akslsYgeYQcsexDaYqP+tsLRP+JRmQ9ZIa1CSsqfVFt7l3ktawOeYysX4KH/ptB4 75ow==
Hi Miroslav,
On Wed, Nov 29, 2023 at 9:05 PM Miroslav Lichvar <mlichvar@xxxxxxxxxx> wrote:
>
> On Wed, Nov 29, 2023 at 11:15:59AM +1100, patrick.oppenlander@xxxxxxxxx wrote:
> > This patch adds support for getting leap second information from the
> > leap-seconds.list file included with tzdata and adds a new configuration
> > directive leapsecdb to switch on the feature.
>
> Good idea.
>
> I have some comments on the design first. Details can be sorted out
> later. Please don't expect this to be ready on first attempt.
In hindsight I should have marked this as an RFC patch.
> > /* ================================================== */
> >
> > +/* Leap second database */
> > +struct leapdb {
> > + long long updated;
> > + long long expiry;
> > + size_t len;
> > + struct leap {
> > + long long when;
> > + int tai_offset;
> > + } leap[];
> > +};
>
> No need to keep this information in memory. Just read the file for
> each request. It's only twice per day.
>
> > + if (leap_db) {
> > + /* Check that the leap database has good data for Jun 30 2012 and Dec 31 2012 */
> > + if (get_db_leap(1341014400, &tai_offset) == LEAP_InsertSecond && tai_offset == 34 &&
> > + get_db_leap(1356912000, &tai_offset) == LEAP_Normal && tai_offset == 35) {
> > + LOG(LOGS_INFO, "Using leap second database %s", leap_db);
> > + } else {
> > + LOG(LOGS_WARN, "Leap second database %s failed check, ignoring", leap_db);
> > + leap_db = NULL;
> > + }
> > + }
>
> Code like this should not be duplicated. I think there should be a
> wrapper around get_tz_leap() and get_db_leap() implementing the
> 12-hour caching logic and the callers shouldn't care which database is
> used.
>
> Also, this is not really relevant to "reference", so it might a good
> opportunity to move it out to separate file, e.g. leapdb.c. The API
> would be just three functions LDB_Initialise(), LDB_GetLeap(),
> LDB_Finalise(). The first commit would refactor the existing code into
> that. The second commit would add the leapfile parsing, documentation
> and some tests.
Thanks for the feedback, I'll prepare a v2.
Patrick
> --
> Miroslav Lichvar
>
>
> --
> To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
> For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
> Trouble? Email listmaster@xxxxxxxxxxxxxxxxxxxx.
>
--
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble? Email listmaster@xxxxxxxxxxxxxxxxxxxx.