listsockets printing 1970's dates. #1043

Closed
opened 2026-10-05 05:00:09 +02:00 by adam · 4 comments
Owner

Juest reported the bug in#znc.

I did a git bisect and finally found the offending commit after a few hours:

42fdf9b49f

[03:00:59] <Test1> list
[03:00:59] <*listsockets> +--------------+-------------------------+----------+-----+----------------+-----------------+-------+-------+
[03:00:59] <*listsockets> | Name         | Created                 | State    | SSL | Local          | Remote          | In    | Out   |
[03:00:59] <*listsockets> +--------------+-------------------------+----------+-----+----------------+-----------------+-------+-------+
[03:00:59] <*listsockets> | _LISTENER    | 1970-01-22 00:15:44.884 | Listener | No  | :: 9999        |                 | 0 B   | 0 B   |
[03:00:59] <*listsockets> | USR::KindOne | 1970-01-22 00:15:46.303 | Inbound  | No  | 127.0.0.1 9999 | 127.0.0.1 54337 | 203 B | 1 KiB |
[03:00:59] <*listsockets> +--------------+-------------------------+----------+-----+----------------+-----------------+-------+-------+
```Juest``` reported the bug in```#znc```. I did a git bisect and finally found the offending commit after a few hours: 42fdf9b49f374849d4177f6e185e70a6541f7d31 ``` [03:00:59] <Test1> list [03:00:59] <*listsockets> +--------------+-------------------------+----------+-----+----------------+-----------------+-------+-------+ [03:00:59] <*listsockets> | Name | Created | State | SSL | Local | Remote | In | Out | [03:00:59] <*listsockets> +--------------+-------------------------+----------+-----+----------------+-----------------+-------+-------+ [03:00:59] <*listsockets> | _LISTENER | 1970-01-22 00:15:44.884 | Listener | No | :: 9999 | | 0 B | 0 B | [03:00:59] <*listsockets> | USR::KindOne | 1970-01-22 00:15:46.303 | Inbound | No | 127.0.0.1 9999 | 127.0.0.1 54337 | 203 B | 1 KiB | [03:00:59] <*listsockets> +--------------+-------------------------+----------+-----+----------------+-----------------+-------+-------+ ``` <!-- github-sync-id:2305270250 -->
adam closed this issue 2026-10-05 05:00:09 +02:00
Author
Owner

Previously, millitime() used gettimeofday to get the current time. With the above update, it is switched to std::chrono::steady_clock::now(). That one uses the monotonic clock and doesn't produce sensible values when interpreted as a wall clock timestamp.

Previously, `millitime()` used `gettimeofday` to get the current time. With the above update, it is switched to `std::chrono::steady_clock::now()`. That one uses the monotonic clock and doesn't produce sensible values when interpreted as a wall clock timestamp. <!-- github-comment-id:2122790826 -->
Author
Owner

Here is a test for when it gets fixed.

$ test/integration/inttest --gtest_filter=ZNCTest.ListsocketsModule
// https://github.com/znc/znc/issues/1910
TEST_F(ZNCTest, ListsocketsModule) {
    auto znc = Run();
    auto ircd = ConnectIRCd();
    auto client = LoginClient();
    client.Write("znc loadmod listsockets");
    client.ReadUntil("Loaded module");
    client.Write("PRIVMSG *listsockets :list");
    // Look for year 20xx, not 1970.
    client.ReadUntil("| _LISTENER       | 20");
}

Here is a test for when it gets fixed. ``` $ test/integration/inttest --gtest_filter=ZNCTest.ListsocketsModule ``` ``` // https://github.com/znc/znc/issues/1910 TEST_F(ZNCTest, ListsocketsModule) { auto znc = Run(); auto ircd = ConnectIRCd(); auto client = LoginClient(); client.Write("znc loadmod listsockets"); client.ReadUntil("Loaded module"); client.Write("PRIVMSG *listsockets :list"); // Look for year 20xx, not 1970. client.ReadUntil("| _LISTENER | 20"); } ``` <!-- github-comment-id:2124858421 -->
Author
Owner

This test will break in year 2100 though :(

This test will break in year 2100 though :( <!-- github-comment-id:2124927099 -->
Author
Owner

Add a TODO and deal with it later.

// TODO: Fix before Year 2100 - https://xkcd.com/1782/
// https://github.com/znc/znc/issues/1910
TEST_F(ZNCTest, ListsocketsModule) {
...
Add a TODO and deal with it later. ``` // TODO: Fix before Year 2100 - https://xkcd.com/1782/ // https://github.com/znc/znc/issues/1910 TEST_F(ZNCTest, ListsocketsModule) { ... ``` <!-- github-comment-id:2128318484 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/znc#1043