Xconf thread shpuld wait for the NTP indicator for network connectivity#367
Open
yogeswaransky wants to merge 2 commits into
Open
Xconf thread shpuld wait for the NTP indicator for network connectivity#367yogeswaransky wants to merge 2 commits into
yogeswaransky wants to merge 2 commits into
Conversation
Signed-off-by: Yogeswaran K <yogeswaran_k@comcast.com>
Contributor
There was a problem hiding this comment.
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/tmpvia 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) |
Contributor
There was a problem hiding this comment.
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>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.