Skip to content

RDKEMW-18410: Xconf thread should wait for the NTP indicator for network connectivity#367

Merged
shibu-kv merged 18 commits into
developfrom
topic/NTP-sync
May 15, 2026
Merged

RDKEMW-18410: Xconf thread should wait for the NTP indicator for network connectivity#367
shibu-kv merged 18 commits into
developfrom
topic/NTP-sync

Conversation

@yogeswaransky
Copy link
Copy Markdown
Contributor

No description provided.

Signed-off-by: Yogeswaran K <yogeswaran_k@comcast.com>
Copilot AI review requested due to automatic review settings May 11, 2026 17:11
@yogeswaransky yogeswaransky requested a review from a team as a code owner May 11, 2026 17:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a boot-time gate in the XConf worker thread to wait for an NTP synchronization indicator file (/tmp/clock-event) before starting TLS-dependent XConf configuration fetches.

Changes:

  • Introduces waitForNTPSync() which watches /tmp via inotify (with a timeout) for creation of /tmp/clock-event.
  • Adds new NTP-sync indicator constants and integrates the wait into getUpdatedConfigurationThread() prior to the existing fetch/retry loop.

Comment thread source/xconf-client/xconfclient.c
Comment thread source/xconf-client/xconfclient.c
Comment thread source/xconf-client/xconfclient.c
Comment thread source/xconf-client/xconfclient.c
Comment thread source/xconf-client/xconfclient.c Outdated
Comment thread source/xconf-client/xconfclient.c Outdated
Copilot AI review requested due to automatic review settings May 12, 2026 12:14
@yogeswaransky yogeswaransky changed the title Xconf thread shpuld wait for the NTP indicator for network connectivity RDKEMW-18410: Xconf thread should wait for the NTP indicator for network connectivity May 12, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

source/xconf-client/xconfclient.c:29

  • The new NTP sync wait code uses errno, time(), and NAME_MAX, but this file doesn’t include the headers that declare/define them. This will fail to compile with modern C compilers (implicit function declarations) and can leave NAME_MAX undefined. Add the missing includes (e.g., <errno.h>, <time.h>, and a header that defines NAME_MAX such as <limits.h>).
#include <string.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/select.h>
#include <sys/inotify.h>
#include <net/if.h>
#include <ifaddrs.h>
#include <stdbool.h>
#include <curl/curl.h>
#include <unistd.h>

Comment thread source/xconf-client/xconfclient.c
Comment thread source/xconf-client/xconfclient.c
Comment thread source/xconf-client/xconfclient.c
Comment thread telemetry2_0.service
Yogeswaran K added 3 commits May 12, 2026 12:20
…ork connectivity

Signed-off-by: Yogeswaran K <yogeswaran_k@comcast.com>
…ork connectivity

Signed-off-by: Yogeswaran K <yogeswaran_k@comcast.com>
Copilot AI review requested due to automatic review settings May 12, 2026 13:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

source/xconf-client/xconfclient.c:33

  • The new NTP wait logic uses errno, NAME_MAX, and time() but this file does not include the headers that define them (<errno.h>, <limits.h>/<linux/limits.h>, and <time.h>). Depending on toolchain flags (e.g., -Werror / C99+), this can fail to compile or rely on non-portable implicit declarations; please add the appropriate includes near the top include block.
#include <string.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/select.h>
#include <sys/inotify.h>
#include <net/if.h>
#include <ifaddrs.h>
#include <stdbool.h>
#include <curl/curl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>

Comment thread source/xconf-client/xconfclient.c
Comment thread source/xconf-client/xconfclient.c
Comment thread source/xconf-client/xconfclient.c
Comment thread telemetry2_0.service Outdated
Yogeswaran K added 2 commits May 12, 2026 13:42
…ork connectivity

Signed-off-by: Yogeswaran K <yogeswaran_k@comcast.com>
…ork connectivity

Signed-off-by: Yogeswaran K <yogeswaran_k@comcast.com>
Copilot AI review requested due to automatic review settings May 12, 2026 13:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

Comment thread telemetry2_0.service Outdated
Comment thread source/xconf-client/xconfclient.c
Comment thread source/xconf-client/xconfclient.c
Comment thread source/xconf-client/xconfclient.c Outdated
Comment thread source/xconf-client/xconfclient.c
Yogeswaran K added 2 commits May 12, 2026 15:32
…ork connectivity

Signed-off-by: Yogeswaran K <yogeswaran_k@comcast.com>
…ork connectivity

Signed-off-by: Yogeswaran K <yogeswaran_k@comcast.com>
Copilot AI review requested due to automatic review settings May 13, 2026 07:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

Comment thread telemetry2_0.service Outdated
Comment thread source/xconf-client/xconfclient.c
Comment thread source/xconf-client/xconfclient.c
Comment thread source/xconf-client/xconfclient.c Outdated
Yogeswaran K added 2 commits May 13, 2026 09:48
…ork connectivity

Signed-off-by: Yogeswaran K <yogeswaran_k@comcast.com>
…ork connectivity

Signed-off-by: Yogeswaran K <yogeswaran_k@comcast.com>
Copilot AI review requested due to automatic review settings May 13, 2026 10:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (3)

source/xconf-client/xconfclient.c:913

  • This fallback path returns after a single 60s sleep even if the NTP indicator still doesn’t exist, which contradicts the stated “wait indefinitely” gating and can cause xconf fetch/TLS to run before time sync. Consider looping (with stop flag checks) until access(NTP_SYNC_INDICATOR) succeeds or shutdown is requested, even when inotify isn’t available.
    {
        T2Error("inotify_init1 failed (errno=%d), falling back to timed wait\n", errno);
        sleep(60);
        return (access(NTP_SYNC_INDICATOR, F_OK) == 0);
    }

source/xconf-client/xconfclient.c:921

  • If NTP_SYNC_DIR doesn’t exist yet (common at boot for /tmp/systimemgr), inotify_add_watch will fail and this path also returns after a single 60s sleep. That makes the “wait for NTP indicator” unreliable. Instead, keep retrying watch setup (or poll access() in a loop) until the indicator appears or shutdown is requested.
    {
        T2Error("inotify_add_watch on %s failed (errno=%d)\n", NTP_SYNC_DIR, errno);
        close(ifd);
        sleep(60);
        return (access(NTP_SYNC_INDICATOR, F_OK) == 0);

source/xconf-client/xconfclient.c:1019

  • Proceeding when waitForNTPSync() returns false undermines the purpose of this change: TLS/xconf fetch may still run with incorrect time and then enter existing retry loops. If waitForNTPSync() fails due to missing directory/inotify issues, it would be safer to keep waiting (with shutdown interrupt) or exit the thread early rather than continuing immediately.
    if (!waitForNTPSync())
    {
        T2Warning("Proceeding without NTP sync confirmation\n");
    }

Comment thread telemetry2_0.service
Comment thread source/xconf-client/xconfclient.c
Yogeswaran K added 2 commits May 13, 2026 15:00
…ork connectivity

Signed-off-by: Yogeswaran K <yogeswaran_k@comcast.com>
…ork connectivity

Signed-off-by: Yogeswaran K <yogeswaran_k@comcast.com>
Copilot AI review requested due to automatic review settings May 13, 2026 15:15
…ork connectivity

Signed-off-by: Yogeswaran K <yogeswaran_k@comcast.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread build_inside_container.sh Outdated
Comment thread source/xconf-client/xconfclient.c Outdated
Comment thread source/xconf-client/xconfclient.c
…ork connectivity

Signed-off-by: Yogeswaran K <yogeswaran_k@comcast.com>
Comment thread build_inside_container.sh Outdated
Copy link
Copy Markdown
Contributor

Copilot AI commented May 14, 2026

@shibu-kv I've opened a new pull request, #368, to work on those changes. Once the pull request is ready, I'll request review from you.

)

* Initial plan

* Disable NTP sync indication flag in container build path

Agent-Logs-Url: https://github.com/rdkcentral/telemetry/sessions/fe1b0563-e051-4df8-a022-0ae17a31725d

Co-authored-by: shibu-kv <89052442+shibu-kv@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: shibu-kv <89052442+shibu-kv@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 14, 2026 19:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

source/xconf-client/xconfclient.c:1018

  • This clock_gettime() result is ignored before now is read. If the call fails, the inotify wait loop compares an uninitialized timestamp against the deadline, making the timeout behavior undefined.
        struct timespec now;
        clock_gettime(CLOCK_MONOTONIC, &now);
        if (now.tv_sec >= deadline.tv_sec)

Comment thread source/xconf-client/xconfclient.c
Comment thread source/xconf-client/xconfclient.c Outdated
Comment thread source/xconf-client/xconfclient.c Outdated
Comment thread source/xconf-client/xconfclient.c
…ork connectivity

Signed-off-by: Yogeswaran K <yogeswaran_k@comcast.com>
@shibu-kv shibu-kv merged commit 5b289c6 into develop May 15, 2026
14 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators May 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants