RDKEMW-21242: Detect log rotation via inode tracking to prevent data loss when new log file grows past seek value#392
Merged
Merged
Conversation
…loss when new log file grows past seek value Signed-off-by: yogeswaransky <yogeswaransky@github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates DCA log-seek persistence and log parsing to detect log rotation via inode tracking, preventing missed data when a rotated/new log file grows beyond the previously stored seek offset.
Changes:
- Introduces
LogSeekInfo { seekValue, inode }and updates seek-map handling to track both fields. - Persists/loads seek state in a new JSON format (while supporting legacy numeric-only seek values).
- Updates DCA log scanning to use inode changes to decide when to read rotated logs and when to re-read the new current log from offset 0, plus adds unit tests for key rotation corner cases.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| source/test/dcautils/dcautilTest.cpp | Updates tests to use LogSeekInfo and adds new inode-rotation corner-case tests. |
| source/dcautil/legacyutils.h | Adds LogSeekInfo and includes sys/types.h for ino_t. |
| source/dcautil/dcautil.c | Updates seek config save/load to persist both seek value and inode (with legacy read support). |
| source/dcautil/dca.c | Adds inode-aware rotation detection and adjusts mmap/rotated-file search behavior accordingly. |
Comments suppressed due to low confidence (1)
source/dcautil/dcautil.c:127
saveSeekConfigtoFileallocates a cJSON array/object tree andcJSON_PrintUnformattedstring but never frees them on the success path, which will leak memory each time seek config is saved.
char *jsonReport = cJSON_PrintUnformatted(valArray);
if(T2ERROR_SUCCESS != saveConfigToFile(SEEKFOLDER, profileName, jsonReport))
{
T2Error("Failed to save config to file\n");
cJSON_Delete(valArray);
free(jsonReport);
return T2ERROR_FAILURE;
}
T2Debug("%s --out\n", __FUNCTION__);
return T2ERROR_SUCCESS;
…loss when new log file grows past seek value Signed-off-by: yogeswaransky <yogeswaransky@github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
source/dcautil/dcautil.c:127
- On the success path,
valArrayandjsonReportare never freed (cJSON_Delete(valArray)/free(jsonReport)), causing a persistent memory leak each time seek config is saved (important on embedded devices). Free both before returning success.
char *jsonReport = cJSON_PrintUnformatted(valArray);
if(T2ERROR_SUCCESS != saveConfigToFile(SEEKFOLDER, profileName, jsonReport))
{
T2Error("Failed to save config to file\n");
cJSON_Delete(valArray);
free(jsonReport);
return T2ERROR_FAILURE;
}
T2Debug("%s --out\n", __FUNCTION__);
return T2ERROR_SUCCESS;
shibu-kv
requested changes
Jul 14, 2026
shibu-kv
left a comment
Contributor
There was a problem hiding this comment.
Minor review comment on NULL checks
…loss when new log file grows past seek value Signed-off-by: yogeswaransky <yogeswaransky@github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (1)
source/dcautil/dcautil.c:136
saveSeekConfigtoFile()leaksvalArrayandjsonReporton the success path. The failure path frees them, but the success path returns withoutcJSON_Delete(valArray)/free(jsonReport), which will accumulate over repeated periodic runs.
char *jsonReport = cJSON_PrintUnformatted(valArray);
if(T2ERROR_SUCCESS != saveConfigToFile(SEEKFOLDER, profileName, jsonReport))
{
T2Error("Failed to save config to file\n");
cJSON_Delete(valArray);
shibu-kv
approved these changes
Jul 14, 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.