未验证 提交 ac22868e 编写于 作者: O openharmony_ci 提交者: Gitee

!218 Add interface of ResetIpc() & macro definition optimization

Merge pull request !218 from liubb_0516/master
......@@ -42,7 +42,7 @@ typedef struct {
uintptr_t cookie;
} SvcIdentity;
#define MIN_BINDER_HANDLE (-1)
#define IPC_INVALID_HANDLE (-1)
#define IPC_IO_INITIALIZED 0x01 /* ipc flag indicates whether io is initialized */
#define IPC_IO_OVERFLOW 0x02 /* ipc flag indicates whether io is running out of space */
#define MAX_IO_SIZE 8192UL
......
......@@ -18,7 +18,5 @@
#define BINDER_DRIVER "/dev/binder"
#define MMAP_MAX_SIZE 262144UL /* 256KB */
#define IPC_IO_DATA_MAX 8192UL
#define MAX_OBJECT_NUM 4
#endif /* OHOS_BINDER_TYPES_H */
\ No newline at end of file
......@@ -229,8 +229,8 @@ static void HandleTransaction(const struct binder_transaction_data *tr)
.args = objectStub->args
};
IpcIo reply;
uint8 tempData[IPC_IO_DATA_MAX];
IpcIoInit(&reply, tempData, IPC_IO_DATA_MAX, MAX_OBJECT_NUM);
uint8 tempData[MAX_IO_SIZE];
IpcIoInit(&reply, tempData, MAX_IO_SIZE, MAX_OBJ_NUM);
int32_t error = OnRemoteRequestInner(tr->code, &data, &reply, option, objectStub);
if (tr->flags & TF_ONE_WAY) {
IpcFreeBuffer((void *)(tr->data.ptr.buffer));
......@@ -421,8 +421,8 @@ static int32_t InternalRequest(SvcIdentity sid, uint32_t code, IpcIo *data, IpcI
data->offsetsCur = data->offsetsBase;
}
if (flags == TF_OP_SYNC && reply != NULL) {
uint8 tempData[IPC_IO_DATA_MAX];
IpcIoInit(reply, tempData, IPC_IO_DATA_MAX, MAX_OBJECT_NUM);
uint8 tempData[MAX_IO_SIZE];
IpcIoInit(reply, tempData, MAX_IO_SIZE, MAX_OBJ_NUM);
}
MessageOption option = {
.flags = flags,
......@@ -521,6 +521,8 @@ static void IpcExitCurrentThread(void)
ioctl(g_connector->fd, BINDER_THREAD_EXIT, 0);
}
static void InvokerResetIpc(void) {}
static BinderConnector *InitBinderConnector(void)
{
if (g_connector == NULL) {
......@@ -547,6 +549,7 @@ static BinderConnector *InitBinderConnector(void)
g_ipcInvoker.AddDeathRecipient = IpcAddDeathRecipient;
g_ipcInvoker.RemoveDeathRecipient = IpcRemoveDeathRecipient;
g_ipcInvoker.ExitCurrentThread = IpcExitCurrentThread;
g_ipcInvoker.InvokerResetIpc = InvokerResetIpc;
}
pthread_mutex_unlock(&g_connectorMutex);
}
......
......@@ -114,7 +114,7 @@ bool ReadRemoteObject(IpcIo *io, SvcIdentity *svc)
}
if (obj->type == BINDER_TYPE_BINDER) {
svc->token = obj->binder;
svc->handle = MIN_BINDER_HANDLE;
svc->handle = IPC_INVALID_HANDLE;
svc->cookie = obj->cookie;
} else {
svc->handle = obj->handle;
......
......@@ -72,6 +72,7 @@ void SendObituary(DeathCallback *deathCallback);
void DeleteDeathCallback(DeathCallback *deathCallback);
void WaitForProxyInit(SvcIdentity *svc);
int32_t DeleteHandle(int32_t handle);
void ResetIpc(void);
#ifdef __cplusplus
#if __cplusplus
}
......
......@@ -40,6 +40,7 @@ typedef struct {
int32_t (*SetRegistryObject)(void);
int32_t (*AddDeathRecipient)(int32_t handle, void *cookie);
int32_t (*RemoveDeathRecipient)(int32_t handle, void *cookie);
void (*InvokerResetIpc)(void);
} RemoteInvoker;
RemoteInvoker *InitRemoteInvoker(int32_t proto);
......
......@@ -420,4 +420,12 @@ void DeleteDeathCallback(DeathCallback *deathCallback)
UtilsListDelete(&deathCallback->list);
pthread_mutex_destroy(&deathCallback->lock);
free(deathCallback);
}
void ResetIpc(void)
{
RemoteInvoker *invoker = GetRemoteInvoker();
if (invoker != NULL && invoker->InvokerResetIpc != NULL) {
(invoker->InvokerResetIpc)();
}
}
\ No newline at end of file
......@@ -189,6 +189,6 @@ int main(int argc, char *argv[])
CallServerAdd();
AnonymousTest();
DeathCallbackTest();
JoinWorkThread();
while (1) {}
return -1;
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册