Compare commits
5 Commits
master
...
OpenHarmon
Author | SHA1 | Date |
---|---|---|
openharmony_ci | 680ec0363a | |
openharmony_ci | 3e26410b25 | |
zjucx | 6358aa926e | |
mamingshuai | 4f293b4c0a | |
openharmony_ci | 45e6069251 |
|
@ -0,0 +1,11 @@
|
|||
### 该问题是怎么引起的?
|
||||
|
||||
|
||||
|
||||
### 重现步骤
|
||||
|
||||
|
||||
|
||||
### 报错信息
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
### 相关的Issue
|
||||
|
||||
|
||||
### 原因(目的、解决的问题等)
|
||||
|
||||
|
||||
### 描述(做了什么,变更了什么)
|
||||
|
||||
|
||||
### 测试用例(新增、改动、可能影响的功能)
|
||||
|
||||
|
|
@ -162,6 +162,29 @@ int SASTORA_FindHandleByPid(SAStore *saStore, pid_t callingPid, PidHandle *handl
|
|||
return INVALID_INDEX;
|
||||
}
|
||||
|
||||
int SASTORA_FindHandleByUidPid(SAStore *saStore, uid_t callingUid, pid_t callingPid, PidHandle *handle)
|
||||
{
|
||||
if (saStore == NULL || saStore->maps == NULL || handle == NULL) {
|
||||
return INVALID_INDEX;
|
||||
}
|
||||
int16 high = saStore->mapTop - 1;
|
||||
int16 low = 0;
|
||||
while (low <= high) {
|
||||
// binary search need div 2
|
||||
int16 mid = (high + low) / 2;
|
||||
if (saStore->maps[mid].pid == callingPid && saStore->maps[mid].uid == callingUid) {
|
||||
*handle = saStore->maps[mid];
|
||||
return mid;
|
||||
}
|
||||
if (saStore->maps[mid].pid < callingPid) {
|
||||
low = mid + 1;
|
||||
continue;
|
||||
}
|
||||
high = mid - 1;
|
||||
}
|
||||
return INVALID_INDEX;
|
||||
}
|
||||
|
||||
PidHandle SASTORA_FindPidHandleByIpcHandle(const SAStore *saStore, uint32 handle)
|
||||
{
|
||||
PidHandle pidHandle = {INVALID_INDEX, INVALID_INDEX, INVALID_INDEX, INVALID_INDEX};
|
||||
|
|
|
@ -75,6 +75,7 @@ static inline void SASTORA_Init(SAStore *saStore)
|
|||
int SASTORA_Save(SAStore *saStore, const char *service, const char *feature, const SvcIdentity *identity);
|
||||
int SASTORA_SaveHandleByPid(SAStore *saStore, PidHandle handle);
|
||||
int SASTORA_FindHandleByPid(SAStore *saStore, pid_t callingPid, PidHandle *handle);
|
||||
int SASTORA_FindHandleByUidPid(SAStore *saStore, uid_t callingUid, pid_t callingPid, PidHandle *handle);
|
||||
SvcIdentity SASTORA_Find(SAStore *saStore, const char *service, const char *feature);
|
||||
int SASTORA_ClearByPid(SAStore *saStore, pid_t pid);
|
||||
PidHandle SASTORA_FindPidHandleByIpcHandle(const SAStore *saStore, uint32 handle);
|
||||
|
|
|
@ -194,10 +194,11 @@ static int32 ProcPutFeature(SamgrServer *server, const void *origin, IpcIo *req,
|
|||
return EC_INVALID;
|
||||
}
|
||||
pid_t pid = GetCallingPid(origin);
|
||||
uid_t uid = GetCallingUid(origin);
|
||||
char *feature = IpcIoPopBool(req) ? NULL : (char *)IpcIoPopString(req, &len);
|
||||
MUTEX_Lock(server->mtx);
|
||||
PidHandle handle;
|
||||
int index = SASTORA_FindHandleByPid(&server->store, pid, &handle);
|
||||
int index = SASTORA_FindHandleByUidPid(&server->store, uid, pid, &handle);
|
||||
if (index == INVALID_INDEX) {
|
||||
MUTEX_Unlock(server->mtx);
|
||||
HILOG_ERROR(HILOG_MODULE_SAMGR, "Endpoint[%d] is not register", pid);
|
||||
|
|
Loading…
Reference in New Issue