From 0e6a93e1ffbcd514218878651c00a6927bb62014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E6=A0=B9=E5=A0=82?= Date: Sat, 25 Mar 2023 10:01:46 +0000 Subject: [PATCH 1/2] =?UTF-8?q?ipc=5Flite=20BinderLinkToDeath=E5=86=85?= =?UTF-8?q?=E5=AD=98=E6=B3=84=E6=BC=8F=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 马根堂 --- .../liteipc_linux/src/liteipc_adapter.c | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/frameworks/liteipc_linux/src/liteipc_adapter.c b/frameworks/liteipc_linux/src/liteipc_adapter.c index 197731e..a109da8 100644 --- a/frameworks/liteipc_linux/src/liteipc_adapter.c +++ b/frameworks/liteipc_linux/src/liteipc_adapter.c @@ -102,11 +102,6 @@ typedef struct { const IpcContext* context; } HdlerArg; -struct BinderDeath { - IpcMsgHandler func; - uint32_t token; -}; - struct FuncPair { UTILS_DL_LIST list; pthread_t tid; @@ -488,12 +483,12 @@ static void HandleReply(IpcIo* bio, const struct binder_transaction_data *txn, u static void HandleDeadBinder(const IpcContext *context, uintptr_t ptr) { - struct BinderDeath *death = (struct BinderDeath *)(uintptr_t) *(binder_uintptr_t *)ptr; + Testament *node = (Testament *)(uintptr_t) *(binder_uintptr_t *)ptr; IpcMsg data = {0}; data.type = MT_DEATH_NOTIFY; - data.target.token = death->token; - data.target.handle = death->token; - death->func(context, &data, NULL, NULL); + data.target.token = node->handle; + data.target.handle = node->handle; + TryCallBack(context, &data, NULL, NULL); } static void BinderRefDone(const IpcContext *context, const struct binder_ptr_cookie *ptrCookie, @@ -1083,22 +1078,16 @@ static inline uint32_t SetDeathHandlerPair(Testament* node, uint32_t index, IpcM return index; } -static void BinderLinkToDeath(const SvcIdentity *sid, IpcMsgHandler callback, const IpcContext* context) +static void BinderLinkToDeath(const SvcIdentity *sid, Testament node, const IpcContext* context) { - struct BinderDeath *bd; struct { uint32_t cmd; struct binder_handle_cookie payload; } __attribute__((packed)) data; - bd = calloc(1, sizeof(struct BinderDeath)); - if (bd == NULL) { - return; - } - bd->func = (void *)callback; - bd->token = sid->handle; + data.cmd = BC_REQUEST_DEATH_NOTIFICATION; data.payload.handle = sid->handle; - data.payload.cookie = (binder_uintptr_t)bd; + data.payload.cookie = node; BinderWrite(context, &data, sizeof(data)); } @@ -1153,7 +1142,7 @@ int32_t RegisterDeathCallback(const IpcContext* context, SvcIdentity sid, IpcMsg node->size = 1; *cbId = SetDeathHandlerPair(node, 0, func, arg); UtilsListAdd(&g_ipcCallbackCb.testaments, &node->list); - BinderLinkToDeath(&sid, (IpcMsgHandler)TryCallBack, tmpContext); + BinderLinkToDeath(&sid, node, tmpContext); UNLOCK_RETURN: pthread_mutex_unlock(&g_ipcCallbackCb.mutex); -- Gitee From effd4d2f2588e1d8b88ae0284b681d73467c9376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E6=A0=B9=E5=A0=82?= Date: Sat, 25 Mar 2023 10:23:22 +0000 Subject: [PATCH 2/2] =?UTF-8?q?ipc=5Flite=20BinderLinkToDeath=E5=86=85?= =?UTF-8?q?=E5=AD=98=E6=B3=84=E6=BC=8F=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 马根堂 --- frameworks/liteipc_linux/src/liteipc_adapter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/liteipc_linux/src/liteipc_adapter.c b/frameworks/liteipc_linux/src/liteipc_adapter.c index a109da8..78b695c 100644 --- a/frameworks/liteipc_linux/src/liteipc_adapter.c +++ b/frameworks/liteipc_linux/src/liteipc_adapter.c @@ -1078,7 +1078,7 @@ static inline uint32_t SetDeathHandlerPair(Testament* node, uint32_t index, IpcM return index; } -static void BinderLinkToDeath(const SvcIdentity *sid, Testament node, const IpcContext* context) +static void BinderLinkToDeath(const SvcIdentity *sid, Testament *node, const IpcContext* context) { struct { uint32_t cmd; -- Gitee