From 7de43bb004a12f926550f0b36ca3c2fa610feb27 Mon Sep 17 00:00:00 2001 From: zhushengle Date: Sat, 26 Jun 2021 10:49:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dkill=E8=BF=9B=E7=A8=8B?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=9B=A0liteipc=E9=98=BB=E5=A1=9E=E7=9A=84?= =?UTF-8?q?=E8=BF=9B=E7=A8=8B=E6=A6=82=E7=8E=87=E6=97=A0=E6=B3=95=E9=80=80?= =?UTF-8?q?=E5=87=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit  kill进程时,会将因为liteipc阻塞的线程唤醒,使其调度并自动退出,由于liteipc阻塞机制为 循环阻塞方式,会导致将因liteipc阻塞的线程唤醒后又进入等待中。此处在唤醒因liteipc阻塞的 线程后检查是否已有kill标志,如果有使其按接收数据失败退出,在返回用户态之前,该线程会进 入退出流程,结束运行。 Close #I3XX7K Signed-off-by: zhushengle Change-Id: Iec4e298dff4aefd2994289067a35cb5673e323f9 --- kernel/base/include/los_task_pri.h | 9 +++++++++ kernel/extended/liteipc/hm_liteipc.c | 11 ++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/kernel/base/include/los_task_pri.h b/kernel/base/include/los_task_pri.h index a4fdf7d3..778f9c00 100644 --- a/kernel/base/include/los_task_pri.h +++ b/kernel/base/include/los_task_pri.h @@ -470,6 +470,15 @@ STATIC INLINE BOOL OsTaskIsPending(const LosTaskCB *taskCB) return FALSE; } +STATIC INLINE BOOL OsTaskIsKilled(const LosTaskCB *taskCB) +{ + if (taskCB->taskStatus & OS_TASK_FLAG_EXIT_KILL) { + return TRUE; + } + + return FALSE; +} + #define OS_TID_CHECK_INVALID(taskID) ((UINT32)(taskID) >= g_taskMaxNum) /* get task info */ diff --git a/kernel/extended/liteipc/hm_liteipc.c b/kernel/extended/liteipc/hm_liteipc.c index 6788815a..fc45bd7d 100644 --- a/kernel/extended/liteipc/hm_liteipc.c +++ b/kernel/extended/liteipc/hm_liteipc.c @@ -108,6 +108,7 @@ typedef enum { READ, READ_DROP, READ_TIMEOUT, + KILL, OPERATION_NUM } IpcOpertion; @@ -1099,6 +1100,14 @@ LITE_OS_SEC_TEXT STATIC UINT32 LiteIpcRead(IpcContent *content) return -ETIME; } + if (OsTaskIsKilled(tcb)) { +#if (LOSCFG_KERNEL_TRACE == YES) + IpcTrace(NULL, KILL, tcb->ipcStatus, syncFlag ? MT_REPLY : MT_REQUEST); +#endif + SCHEDULER_UNLOCK(intSave); + return -ERFKILL; + } + SCHEDULER_UNLOCK(intSave); } else { listNode = LOS_DL_LIST_FIRST(listHead); @@ -1178,7 +1187,7 @@ BUFFER_FREE: if ((content->flag & RECV) == RECV) { ret = LiteIpcRead(content); if (ret != LOS_OK) { - PRINT_ERR("LiteIpcRead failed\n"); + PRINT_ERR("LiteIpcRead failed ERROR: %d\n", (INT32)ret); return ret; } UINT32 offset = LOS_OFF_SET_OF(IpcContent, inMsg);