diff --git a/frameworks/liteipc_linux/src/liteipc_adapter.c b/frameworks/liteipc_linux/src/liteipc_adapter.c index 197731e28bba4ccaf7fb7fb044338300f1a84841..78b695c05b33a750d501dcbe0f9cc00ed74b7a7f 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);