Skip to content

RDKEMW-19033: [support/8.4.4.0] Xconf thread should wait Indefinitely for the NTP indicator#375

Merged
shibu-kv merged 1 commit into
support/1.7.3from
feature/RDKEMW-19033
May 26, 2026
Merged

RDKEMW-19033: [support/8.4.4.0] Xconf thread should wait Indefinitely for the NTP indicator#375
shibu-kv merged 1 commit into
support/1.7.3from
feature/RDKEMW-19033

Conversation

@yogeswaransky
Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings May 26, 2026 05:17
@yogeswaransky yogeswaransky requested a review from a team as a code owner May 26, 2026 05: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

Gates the XConf fetch worker at startup behind an optional, platform-provided NTP-sync indicator file so that XConf HTTPS requests do not run against an unsynchronized clock (which can break TLS certificate validation). The wait is compiled in only when NTP_SYNC_INDICATION is defined, and on RDKB watches /tmp/clock-event while other platforms watch /tmp/systimemgr/ntp.

Changes:

  • Adds new headers (errno.h, limits.h, time.h, sys/select.h, sys/inotify.h) and a feature-flag-gated block defining NTP_SYNC_INDICATOR, NTP_SYNC_DIR, NTP_SYNC_FILENAME, and NTP_SYNC_DIR_WAIT_TIMEOUT_SEC (30 min) with per-platform paths.
  • Introduces waitForNTPSync() (inotify on the indicator's directory with a 2 s select() for interruptibility, plus fast-path and race re-check) and waitForNTPSyncDir() (polls up to 30 min on CLOCK_MONOTONIC if the watch directory is not yet present).
  • Calls waitForNTPSync() once at the start of getUpdatedConfigurationThread(), before the existing URL/config fetch loop, releasing/re-acquiring xcThreadMutex around the wait.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1474 to +1476
pthread_mutex_lock(&xcThreadMutex);
bool shouldStop = stopFetchRemoteConfiguration;
pthread_mutex_unlock(&xcThreadMutex);
Comment on lines +1429 to +1456
int wd = inotify_add_watch(ifd, NTP_SYNC_DIR, IN_CREATE | IN_MOVED_TO);
if (wd < 0)
{
/*
* Most likely cause: NTP_SYNC_DIR does not exist yet (e.g. /tmp/systimemgr
* is created by systimemgr at startup). Wait up to 30 minutes for the
* directory to appear.
*/
T2Warning("inotify_add_watch on %s failed with errno=%d, waiting for directory\n", NTP_SYNC_DIR, errno);

int dirResult = waitForNTPSyncDir();
if (dirResult < 0)
{
/* Timeout or shutdown — directory never appeared */
close(ifd);
return false;
}

/* Directory appeared — retry inotify_add_watch */
wd = inotify_add_watch(ifd, NTP_SYNC_DIR, IN_CREATE | IN_MOVED_TO);
if (wd < 0)
{
T2Error("inotify_add_watch on %s still fails with errno=%d after dir appeared, proceeding without NTP sync\n",
NTP_SYNC_DIR, errno);
close(ifd);
return false;
}
}
Comment on lines +1484 to +1506
/* select() with 2s timeout for interruptibility */
struct timeval tv;
tv.tv_sec = 2;
tv.tv_usec = 0;

fd_set fds;
FD_ZERO(&fds);
FD_SET(ifd, &fds);

int ret = select(ifd + 1, &fds, NULL, NULL, &tv);
if (ret < 0)
{
if (errno == EINTR)
{
continue;
}
T2Error("select() failed with errno=%d\n", errno);
break;
}
if (ret == 0)
{
continue; /* timeout, loop back to check shutdown flag */
}
@shibu-kv shibu-kv merged commit ed49385 into support/1.7.3 May 26, 2026
10 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators May 26, 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.

3 participants