diff options
author | Bui Nguyen Quoc Thanh <Thanh.BuiNguyenQuoc@vn.bosch.com> | 2019-05-09 17:12:54 +0700 |
---|---|---|
committer | Saya Sugiura <ssugiura@jp.adit-jv.com> | 2019-06-18 17:22:09 +0900 |
commit | 86fabee83872e567620bca6fcfd8b10135f2ed46 (patch) | |
tree | ecca63ca2bbe229cd98a9238cab873b039492e17 /src/offlinelogstorage/dlt_offline_logstorage_behavior.c | |
parent | 711c9b884cf8f869511b31133dc9f7959c9ab843 (diff) | |
download | DLT-daemon-86fabee83872e567620bca6fcfd8b10135f2ed46.tar.gz |
Logstorage: Correct behavior in sync message cache
If the message size is equal to remaining size of cache, it is still
written into cache. And then whole cache data must be synchronized to
file according to strategy.
Signed-off-by: Bui Nguyen Quoc Thanh <Thanh.BuiNguyenQuoc@vn.bosch.com>
Diffstat (limited to 'src/offlinelogstorage/dlt_offline_logstorage_behavior.c')
-rw-r--r-- | src/offlinelogstorage/dlt_offline_logstorage_behavior.c | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/src/offlinelogstorage/dlt_offline_logstorage_behavior.c b/src/offlinelogstorage/dlt_offline_logstorage_behavior.c index f4d1d97..2637936 100644 --- a/src/offlinelogstorage/dlt_offline_logstorage_behavior.c +++ b/src/offlinelogstorage/dlt_offline_logstorage_behavior.c @@ -997,8 +997,21 @@ int dlt_logstorage_write_msg_cache(DltLogStorageFilterConfig *config, if (footer->wrap_around_cnt < 1) { footer->end_sync_offset = footer->offset; } + + /* write data to cache */ + memcpy(curr_write_addr, data1, size1); + curr_write_addr += size1; + memcpy(curr_write_addr, data2, size2); + curr_write_addr += size2; + memcpy(curr_write_addr, data3, size3); } - else + + /* + * In case the msg_size is equal to remaining cache size, + * the message is still written in cache. + * Then whole cache data is synchronized to file. + */ + if (msg_size >= remain_cache_size) { /*check for message size exceeds cache size for specific_size strategy */ if ((unsigned int) msg_size > cache_size) @@ -1043,18 +1056,22 @@ int dlt_logstorage_write_msg_cache(DltLogStorageFilterConfig *config, footer->wrap_around_cnt += 1; } - /* start writing from beginning */ - footer->end_sync_offset = footer->offset; - curr_write_addr = config->cache; - footer->offset = msg_size; + if (msg_size > remain_cache_size) + { + /* start writing from beginning */ + footer->end_sync_offset = footer->offset; + curr_write_addr = config->cache; + footer->offset = msg_size; + + /* write data to cache */ + memcpy(curr_write_addr, data1, size1); + curr_write_addr += size1; + memcpy(curr_write_addr, data2, size2); + curr_write_addr += size2; + memcpy(curr_write_addr, data3, size3); + } } - /* write data to cache */ - memcpy(curr_write_addr, data1, size1); - curr_write_addr += size1; - memcpy(curr_write_addr, data2, size2); - curr_write_addr += size2; - memcpy(curr_write_addr, data3, size3); return 0; } |