mirror of
https://gitee.com/openharmony/startup_init
synced 2024-11-27 02:10:33 +00:00
fix bug UpdateParam and add dfx log
Signed-off-by: zhouge <zhouge7@huawei.com>
This commit is contained in:
parent
6258be80a4
commit
6c77d19b56
@ -32,6 +32,7 @@ extern "C" {
|
||||
#define WORKSPACE_STATUS_IN_PROCESS 0x01
|
||||
#define WORKSPACE_STATUS_VALID 0x02
|
||||
|
||||
#define READ_COMMIT_ID_LOOP_RETRY_TIME_WARNING 50
|
||||
#ifndef PARAM_BASE
|
||||
#define PARAM_SPRINTF(buffer, buffSize, format, ...) \
|
||||
snprintf_s((buffer), (buffSize), (buffSize) - 1, (format), ##__VA_ARGS__)
|
||||
@ -46,9 +47,13 @@ extern "C" {
|
||||
static inline uint32_t ReadCommitId(ParamNode *entry)
|
||||
{
|
||||
uint32_t commitId = ATOMIC_LOAD_EXPLICIT(&entry->commitId, MEMORY_ORDER_ACQUIRE);
|
||||
uint32_t retryTimes = 0;
|
||||
while (commitId & PARAM_FLAGS_MODIFY) {
|
||||
futex_wait(&entry->commitId, commitId);
|
||||
commitId = ATOMIC_LOAD_EXPLICIT(&entry->commitId, MEMORY_ORDER_ACQUIRE);
|
||||
if (retryTimes++ % READ_COMMIT_ID_LOOP_RETRY_TIME_WARNING == 0) {
|
||||
PARAM_LOGW("ReadCommitId warning, too many retry times, %{public}d", retryTimes);
|
||||
}
|
||||
}
|
||||
return commitId & PARAM_FLAGS_COMMITID;
|
||||
}
|
||||
|
@ -461,7 +461,8 @@ static int UpdateParam(const WorkSpace *workSpace, uint32_t *dataIndex, const ch
|
||||
entry->valueLength = valueLen;
|
||||
}
|
||||
uint32_t flags = commitId & ~PARAM_FLAGS_COMMITID;
|
||||
ATOMIC_STORE_EXPLICIT(&entry->commitId, (++commitId) | flags, MEMORY_ORDER_RELEASE);
|
||||
uint32_t commitIdCount = (++commitId) & PARAM_FLAGS_COMMITID;
|
||||
ATOMIC_STORE_EXPLICIT(&entry->commitId, flags | commitIdCount, MEMORY_ORDER_RELEASE);
|
||||
ATOMIC_SYNC_ADD_AND_FETCH(&workSpace->area->commitId, 1, MEMORY_ORDER_RELEASE);
|
||||
#ifdef PARAM_SUPPORT_SELINUX
|
||||
WorkSpace *space = GetWorkSpace(WORKSPACE_INDEX_DAC);
|
||||
|
Loading…
Reference in New Issue
Block a user