mirror of
https://gitee.com/openharmony/startup_init
synced 2024-12-02 16:06:31 +00:00
add mutex for workspace
Signed-off-by: Mupceet <laiguizhong@huawei.com>
This commit is contained in:
parent
466ea2958e
commit
4e94e0bb77
@ -211,7 +211,7 @@ static int CheckFilePermission(const ParamSecurityLabel *localLabel, const char
|
||||
static int CheckUserInGroup(WorkSpace *space, gid_t groupId, uid_t uid)
|
||||
{
|
||||
#ifdef __MUSL__
|
||||
static char buffer[USER_BUFFER_LEN] = {0};
|
||||
char buffer[USER_BUFFER_LEN] = {0};
|
||||
uint32_t labelIndex = 0;
|
||||
int ret = ParamSprintf(buffer, sizeof(buffer), "%s.%d.%d", GROUP_FORMAT, groupId, uid);
|
||||
PARAM_CHECK(ret >= 0, return -1, "Failed to format name for %s.%d.%d", GROUP_FORMAT, groupId, uid);
|
||||
|
@ -29,23 +29,37 @@ void paramMutexEnvInit(void)
|
||||
|
||||
int ParamRWMutexCreate(ParamRWMutex *lock)
|
||||
{
|
||||
PARAM_CHECK(lock != NULL, return -1, "Invalid lock");
|
||||
pthread_rwlockattr_t rwlockatt;
|
||||
pthread_rwlockattr_init(&rwlockatt);
|
||||
pthread_rwlockattr_setpshared(&rwlockatt, PTHREAD_PROCESS_SHARED);
|
||||
pthread_rwlock_init(&lock->rwlock, &rwlockatt);
|
||||
return 0;
|
||||
}
|
||||
int ParamRWMutexWRLock(ParamRWMutex *lock)
|
||||
{
|
||||
PARAM_CHECK(lock != NULL, return -1, "Invalid lock");
|
||||
pthread_rwlock_wrlock(&lock->rwlock);
|
||||
return 0;
|
||||
}
|
||||
int ParamRWMutexRDLock(ParamRWMutex *lock)
|
||||
{
|
||||
PARAM_CHECK(lock != NULL, return -1, "Invalid lock");
|
||||
pthread_rwlock_rdlock(&lock->rwlock);
|
||||
return 0;
|
||||
}
|
||||
int ParamRWMutexUnlock(ParamRWMutex *lock)
|
||||
{
|
||||
PARAM_CHECK(lock != NULL, return -1, "Invalid lock");
|
||||
pthread_rwlock_unlock(&lock->rwlock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ParamRWMutexDelete(ParamRWMutex *lock)
|
||||
{
|
||||
PARAM_CHECK(lock != NULL, return -1, "Invalid lock");
|
||||
uint32_t ret = pthread_rwlock_destroy(&lock->rwlock);
|
||||
PARAM_CHECK(ret == 0, return -1, "Failed to mutex lock ret %d", ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,6 @@ __attribute__((constructor)) static void ParameterInit(void)
|
||||
return;
|
||||
}
|
||||
EnableInitLog(INIT_INFO);
|
||||
PARAM_LOGI("ParameterInit ");
|
||||
InitParamWorkSpace(1);
|
||||
}
|
||||
|
||||
@ -51,7 +50,6 @@ __attribute__((destructor)) static void ParameterDeinit(void)
|
||||
close(g_clientFd);
|
||||
g_clientFd = INVALID_SOCKET;
|
||||
}
|
||||
CloseParamWorkSpace();
|
||||
pthread_mutex_destroy(&g_clientMutex);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user