RDKEMW-19033: [support/8.4.4.0] Xconf thread should wait Indefinitely for the NTP indicator#375
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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 definingNTP_SYNC_INDICATOR,NTP_SYNC_DIR,NTP_SYNC_FILENAME, andNTP_SYNC_DIR_WAIT_TIMEOUT_SEC(30 min) with per-platform paths. - Introduces
waitForNTPSync()(inotify on the indicator's directory with a 2 sselect()for interruptibility, plus fast-path and race re-check) andwaitForNTPSyncDir()(polls up to 30 min onCLOCK_MONOTONICif the watch directory is not yet present). - Calls
waitForNTPSync()once at the start ofgetUpdatedConfigurationThread(), before the existing URL/config fetch loop, releasing/re-acquiringxcThreadMutexaround 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
approved these changes
May 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.