head 1.3; access; symbols pkgsrc-2026Q1:1.3.0.86 pkgsrc-2026Q1-base:1.3 pkgsrc-2025Q4:1.3.0.84 pkgsrc-2025Q4-base:1.3 pkgsrc-2025Q3:1.3.0.82 pkgsrc-2025Q3-base:1.3 pkgsrc-2025Q2:1.3.0.80 pkgsrc-2025Q2-base:1.3 pkgsrc-2025Q1:1.3.0.78 pkgsrc-2025Q1-base:1.3 pkgsrc-2024Q4:1.3.0.76 pkgsrc-2024Q4-base:1.3 pkgsrc-2024Q3:1.3.0.74 pkgsrc-2024Q3-base:1.3 pkgsrc-2024Q2:1.3.0.72 pkgsrc-2024Q2-base:1.3 pkgsrc-2024Q1:1.3.0.70 pkgsrc-2024Q1-base:1.3 pkgsrc-2023Q4:1.3.0.68 pkgsrc-2023Q4-base:1.3 pkgsrc-2023Q3:1.3.0.66 pkgsrc-2023Q3-base:1.3 pkgsrc-2023Q2:1.3.0.64 pkgsrc-2023Q2-base:1.3 pkgsrc-2023Q1:1.3.0.62 pkgsrc-2023Q1-base:1.3 pkgsrc-2022Q4:1.3.0.60 pkgsrc-2022Q4-base:1.3 pkgsrc-2022Q3:1.3.0.58 pkgsrc-2022Q3-base:1.3 pkgsrc-2022Q2:1.3.0.56 pkgsrc-2022Q2-base:1.3 pkgsrc-2022Q1:1.3.0.54 pkgsrc-2022Q1-base:1.3 pkgsrc-2021Q4:1.3.0.52 pkgsrc-2021Q4-base:1.3 pkgsrc-2021Q3:1.3.0.50 pkgsrc-2021Q3-base:1.3 pkgsrc-2021Q2:1.3.0.48 pkgsrc-2021Q2-base:1.3 pkgsrc-2021Q1:1.3.0.46 pkgsrc-2021Q1-base:1.3 pkgsrc-2020Q4:1.3.0.44 pkgsrc-2020Q4-base:1.3 pkgsrc-2020Q3:1.3.0.42 pkgsrc-2020Q3-base:1.3 pkgsrc-2020Q2:1.3.0.38 pkgsrc-2020Q2-base:1.3 pkgsrc-2020Q1:1.3.0.18 pkgsrc-2020Q1-base:1.3 pkgsrc-2019Q4:1.3.0.40 pkgsrc-2019Q4-base:1.3 pkgsrc-2019Q3:1.3.0.36 pkgsrc-2019Q3-base:1.3 pkgsrc-2019Q2:1.3.0.34 pkgsrc-2019Q2-base:1.3 pkgsrc-2019Q1:1.3.0.32 pkgsrc-2019Q1-base:1.3 pkgsrc-2018Q4:1.3.0.30 pkgsrc-2018Q4-base:1.3 pkgsrc-2018Q3:1.3.0.28 pkgsrc-2018Q3-base:1.3 pkgsrc-2018Q2:1.3.0.26 pkgsrc-2018Q2-base:1.3 pkgsrc-2018Q1:1.3.0.24 pkgsrc-2018Q1-base:1.3 pkgsrc-2017Q4:1.3.0.22 pkgsrc-2017Q4-base:1.3 pkgsrc-2017Q3:1.3.0.20 pkgsrc-2017Q3-base:1.3 pkgsrc-2017Q2:1.3.0.16 pkgsrc-2017Q2-base:1.3 pkgsrc-2017Q1:1.3.0.14 pkgsrc-2017Q1-base:1.3 pkgsrc-2016Q4:1.3.0.12 pkgsrc-2016Q4-base:1.3 pkgsrc-2016Q3:1.3.0.10 pkgsrc-2016Q3-base:1.3 pkgsrc-2016Q2:1.3.0.8 pkgsrc-2016Q2-base:1.3 pkgsrc-2016Q1:1.3.0.6 pkgsrc-2016Q1-base:1.3 pkgsrc-2015Q4:1.3.0.4 pkgsrc-2015Q4-base:1.3 pkgsrc-2015Q3:1.3.0.2 pkgsrc-2015Q3-base:1.3 pkgsrc-2015Q2:1.2.0.4 pkgsrc-2015Q2-base:1.2 pkgsrc-2015Q1:1.2.0.2 pkgsrc-2015Q1-base:1.2 pkgsrc-2014Q4:1.1.0.2 pkgsrc-2014Q4-base:1.1; locks; strict; comment @// @; 1.3 date 2015.07.01.09.22.20; author he; state Exp; branches; next 1.2; commitid qaPWK5Lmy8T9Yyry; 1.2 date 2015.01.13.20.25.13; author he; state Exp; branches; next 1.1; commitid fLkPiNLokXMf4U5y; 1.1 date 2014.12.09.10.45.51; author he; state Exp; branches; next ; commitid gADsJpDHWPH6Zl1y; desc @@ 1.3 log @It looks like we need another round of changes to get_timestamp(), this time from using gettimeofday() to using cloc_gettime(CLOCK_MONOTONIC), to avoid the effects of UTC leap second insertion which IIUC steps the system clock back one second, and will cause the single assert() in dbeacon.cpp to fire. Unfortunately, my core dump was incomplete due to a full root file system... PKGREVISION bumped. @ text @$NetBSD: patch-dbeacon__posix.cpp,v 1.2 2015/01/13 20:25:13 he Exp $ Replace use of times() with clock_gettime(CLOCK_MONOTONIC), since all we use it for is to get a millisecond timestamp, and with a 32-bit unsigned clock_t and 100Hz tick, times() wraps around every 500 days or so, and the code then falls into an assert() in dbeacon.cpp. Still retry a few times if clock_gettime() for some reason should decide to fail. --- dbeacon_posix.cpp.orig 2007-06-09 11:35:57.000000000 +0000 +++ dbeacon_posix.cpp @@@@ -23,8 +23,10 @@@@ #include #include #include +#include #include #include +#include #include #include @@@@ -515,11 +517,24 @@@@ void address::set(const sockaddr *sa) { } uint64_t get_timestamp() { - struct tms tmp; + struct timespec ts; + uint64_t timestamp; + int n = 0; - uint64_t v = times(&tmp); + retry: + if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) { + log(LOG_WARNING, "clock_gettime(CLOCK_MONOTONIC) failed: %m"); + if (++n < 5) + goto retry; + else + log(LOG_ERR, + "clock_gettime(CLOCK_MONOTONIC) failed after 5 retries: %m"); + } + timestamp = ts.tv_sec; + timestamp *= 1000; + timestamp += ts.tv_nsec / 1000000; - return (v * 1000) / sysconf(_SC_CLK_TCK); + return timestamp; } uint64_t get_time_of_day() { @ 1.2 log @Re-do the get_timestamp() patch to instead of calling times() use gettimeofday() directly. With a 32-bit clock_t and a 100Hz tick, times() will wrap once every 497 days if my math isn't too far off, and this will land us in an assert() in dbeacon and with a core dump. So instead use gettimeofday() and save 2 x getrusage() per earlier times() call. Retain some protection against gettimeofday() failing. Bump PKGREVISION. @ text @d1 1 a1 1 $NetBSD: patch-dbeacon__posix.cpp,v 1.1 2014/12/09 10:45:51 he Exp $ d3 5 a7 4 Replace use of times() with gettimeofday(), since all we use it for is to get a millisecond timestamp, and with a 32-bit unsigned clock_t and 100Hz tick, times() wraps around every 500 days or so, and the code then falls into an assert() in dbeacon.cpp. d9 1 a9 1 Still retry a few times if gettimeofday() for some reason should d14 3 a16 1 @@@@ -25,6 +25,7 @@@@ d18 1 d25 1 a25 1 @@@@ -515,11 +516,24 @@@@ void address::set(const sockaddr *sa) { d30 1 a30 1 + struct timeval tv; d36 2 a37 2 + if (gettimeofday(&tv, 0) != 0) { + log(LOG_WARNING, "gettimeofday() failed: %m"); d42 1 a42 1 + "gettimeofday() failed after 5 retries: %m"); d44 1 a44 1 + timestamp = tv.tv_sec; d46 1 a46 1 + timestamp += tv.tv_usec / 1000; @ 1.1 log @It can happen that times() returns ((uint32_t)-1). If that happens, retry a limited number of times, and log the events. Export log() from the main program for use in dbeacon_posix.cpp. Fix the matrix.pl script since qw() no longer acts as parenteses, so add some of our own where called for. Bump PKGREVISION. @ text @d1 1 a1 1 $NetBSD$ d3 7 a9 2 Retry if times() returns with an error. It has been known to return ((uint32_t)-1). d21 2 a22 1 @@@@ -516,10 +517,19 @@@@ void address::set(const sockaddr *sa) { d25 3 a27 2 struct tms tmp; + clock_t clk; a30 2 - - return (v * 1000) / sysconf(_SC_CLK_TCK); d32 2 a33 3 + clk = times(&tmp); + if (errno != 0) { + log(LOG_WARNING, "times() failed: %m"); d37 2 a38 1 + log(LOG_ERR, "times() failed after 5 retries: %m"); d40 6 a45 1 + return (clk * 1000) / sysconf(_SC_CLK_TCK); @