Skip to content

Xconf thread shpuld wait for the NTP indicator for network connectivity#367

Open
yogeswaransky wants to merge 2 commits into
developfrom
topic/NTP-sync
Open

Xconf thread shpuld wait for the NTP indicator for network connectivity#367
yogeswaransky wants to merge 2 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.

@@ -20,6 +20,8 @@
#include <string.h>
#include <stdlib.h>
Comment on lines +925 to +931
while (!result)
{
if (stopFetchRemoteConfiguration)
{
T2Info("NTP wait interrupted by shutdown\n");
break;
}
Comment on lines +921 to +935
bool result = false;
time_t deadline = time(NULL) + NTP_SYNC_TIMEOUT_SEC;
char buf[sizeof(struct inotify_event) + NAME_MAX + 1];

while (!result)
{
if (stopFetchRemoteConfiguration)
{
T2Info("NTP wait interrupted by shutdown\n");
break;
}

time_t remaining = deadline - time(NULL);
if (remaining <= 0)
{
Comment on lines +895 to +901
int ifd = inotify_init1(IN_CLOEXEC);
if (ifd < 0)
{
T2Error("inotify_init1 failed (errno=%d), falling back to timed wait\n", errno);
sleep(60);
return (access(NTP_SYNC_INDICATOR, F_OK) == 0);
}
#define NTP_SYNC_INDICATOR "/tmp/clock-event"
#define NTP_SYNC_DIR "/tmp"
#define NTP_SYNC_FILENAME "clock-event"
#define NTP_SYNC_TIMEOUT_SEC 1200

while (!result)
{
if (stopFetchRemoteConfiguration)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Data race condition

Accessing "stopFetchRemoteConfiguration" without holding lock "xcThreadMutex". Elsewhere, "stopFetchRemoteConfiguration" is written to with "xcThreadMutex" held 5 out of 5 times (3 of these accesses strongly imply that it is necessary).

Medium Impact, CWE-366
MISSING_LOCK

Signed-off-by: Yogeswaran K <yogeswaran_k@comcast.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants