]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: sample: apply the ms_/us_ time offsets in the input unit
authorWilly Tarreau <w@1wt.eu>
Wed, 30 Sep 2026 07:23:47 +0000 (09:23 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 30 Sep 2026 14:11:24 +0000 (16:11 +0200)
commit31703b81bb12cf1c80362a46a0d89af07afff327
tree8c945ea8975c49ea4511430d46c75e67693a25aa
parentf9dd42a9c1c337a846683910a9f9c8f6184c3479
BUG/MINOR: sample: apply the ms_/us_ time offsets in the input unit

The documentation of ms_ltime(), ms_utime(), us_ltime() and us_utime()
states that their optional <offset> is expressed in milliseconds or in
microseconds, that is in the same unit as their input. The four of them
however split the input into a number of seconds and a sub-second part
first, and then add the offset to the number of seconds, so the offset
was really applied in seconds and could never shift the sub-second part.

With int(1234567890123),ms_utime("%H:%M:%S.%3N",877) the result was
23:46:07.123, that is 877 seconds later, instead of the 23:31:31.000
the documentation describes.

The offset is now added to the input before it is split, which also
lets it carry the sub-second part as intended. The plain ltime() and
utime() take their offset in seconds and are unaffected.

The bug was introduced with the converters in 2.9-dev3 with commit
5e63e1636a ("MEDIUM: sample: implement us and ms variant of utime and
ltime"), so the fix must be backported as far as 3.0.
src/sample.c