diff options
author | Bui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com> | 2020-05-29 11:27:49 +0700 |
---|---|---|
committer | Saya Sugiura <39760799+ssugiura@users.noreply.github.com> | 2020-07-06 10:04:07 +0900 |
commit | 1e17f03f95ba4cb6802664f9449ad804490bb557 (patch) | |
tree | 37d950832bf86b36382b71f5a0b958ccbeb4b51e /src/offlinelogstorage | |
parent | 4fc46e455a306db32848311043af5ecdbc2a2ee9 (diff) | |
download | DLT-daemon-1e17f03f95ba4cb6802664f9449ad804490bb557.tar.gz |
logstorage: fix syncbehaviour
- In case sync is not ON_MSG, the newest file information
does not need to be updated.
Signed-off-by: Bui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com>
Diffstat (limited to 'src/offlinelogstorage')
-rw-r--r-- | src/offlinelogstorage/dlt_offline_logstorage.c | 70 |
1 files changed, 44 insertions, 26 deletions
diff --git a/src/offlinelogstorage/dlt_offline_logstorage.c b/src/offlinelogstorage/dlt_offline_logstorage.c index 09f7c06..5b607f5 100644 --- a/src/offlinelogstorage/dlt_offline_logstorage.c +++ b/src/offlinelogstorage/dlt_offline_logstorage.c @@ -766,7 +766,9 @@ DLT_STATIC int dlt_logstorage_prepare_table(DltLogStorage *handle, return -1; } - if (data->file_name) { + if ((data->sync == DLT_LOGSTORAGE_SYNC_ON_MSG || + data->sync == DLT_LOGSTORAGE_SYNC_UNSET) && + (data->file_name)) { if (handle->newest_file_list != NULL) { tmp = handle->newest_file_list; while (tmp) { @@ -2091,36 +2093,52 @@ int dlt_logstorage_write(DltLogStorage *handle, if (config[i]->file_name == NULL) continue; - tmp = handle->newest_file_list; - while (tmp) { - if (strcmp(tmp->file_name, config[i]->file_name) == 0) { - found = 1; - break; + /* The newest file must be applied to only ON_MSG */ + if ((config[i]->sync == DLT_LOGSTORAGE_SYNC_ON_MSG || + config[i]->sync == DLT_LOGSTORAGE_SYNC_UNSET)) { + tmp = handle->newest_file_list; + while (tmp) { + if (strcmp(tmp->file_name, config[i]->file_name) == 0) { + found = 1; + break; + } + else { + tmp = tmp->next; + } } - else { - tmp = tmp->next; + if (!found) { + dlt_vlog(LOG_ERR, "Cannot find out record for filename [%s]\n", + config[i]->file_name); + return -1; } - } - if (!found) { - dlt_vlog(LOG_ERR, "Cannot find out record for filename [%s]\n", - config[i]->file_name); - return -1; - } - /* prepare log file (create and/or open)*/ - ret = config[i]->dlt_logstorage_prepare(config[i], - uconfig, - handle->device_mount_point, - size1 + size2 + size3, - tmp->newest_file); - if (tmp->newest_file == NULL || - strcmp(config[i]->working_file_name, tmp->newest_file) != 0) { - if (tmp->newest_file) { - free(tmp->newest_file); - tmp->newest_file = NULL; + /* prepare log file (create and/or open)*/ + ret = config[i]->dlt_logstorage_prepare(config[i], + uconfig, + handle->device_mount_point, + size1 + size2 + size3, + tmp->newest_file); + + if ((tmp->newest_file == NULL || + strcmp(config[i]->working_file_name, tmp->newest_file) != 0)) { + if (tmp->newest_file) { + free(tmp->newest_file); + tmp->newest_file = NULL; + } + tmp->newest_file = strdup(config[i]->working_file_name); } - tmp->newest_file = strdup(config[i]->working_file_name); } + else { + /* In case SyncBehaviour differs from ON_MSG, + * do not need to update the newest file name + */ + ret = config[i]->dlt_logstorage_prepare(config[i], + uconfig, + handle->device_mount_point, + size1 + size2 + size3, + NULL); + } + if (ret == 0) { /* log data (write) */ ret = config[i]->dlt_logstorage_write(config[i], |