From f599230bef4d541262aefd8c943d9ff84c5b6dbd Mon Sep 17 00:00:00 2001 From: lixinpeng Date: Sun, 7 Apr 2024 15:57:47 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=94=81=E4=BF=9D?= =?UTF-8?q?=E6=8A=A4=20Signed-off-by:=20lixinpeng=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/ims/input_event_client_proxy.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/ims/input_event_client_proxy.cpp b/services/ims/input_event_client_proxy.cpp index fe5486b..900b1a5 100644 --- a/services/ims/input_event_client_proxy.cpp +++ b/services/ims/input_event_client_proxy.cpp @@ -45,9 +45,11 @@ void InputEventClientProxy::ClientRequestHandle(int funcId, void* origin, IpcIo* void InputEventClientProxy::AddListener(const void* origin, IpcIo* req, IpcIo* reply) { if (clientInfoMap_.size() >= MAX_CLIENT_SIZE) { + pthread_mutex_unlock(&lock_); GRAPHIC_LOGE("Exceeded the maximum number!"); return; } + pthread_mutex_unlock(&lock_); pid_t pid = GetCallingPid(); SvcIdentity svc = {0}; bool ret = ReadRemoteObject(req, &svc); @@ -76,12 +78,14 @@ void InputEventClientProxy::DeathCallback(void* origin) void InputEventClientProxy::RemoveListener(const void* origin, IpcIo* req, IpcIo* reply) { pid_t pid = GetCallingPid(); + pthread_mutex_lock(&lock_); if (clientInfoMap_.count(pid) > 0) { ReleaseSvc(clientInfoMap_[pid].svc); pthread_mutex_lock(&lock_); clientInfoMap_.erase(pid); pthread_mutex_unlock(&lock_); } + pthread_mutex_unlock(&lock_); } void InputEventClientProxy::OnRawEvent(const RawEvent& event) -- Gitee From a851294a87ba1502dfd8168c39fb80cd0cff78aa Mon Sep 17 00:00:00 2001 From: lixinpeng Date: Sun, 7 Apr 2024 09:13:18 +0000 Subject: [PATCH 2/2] update services/ims/input_event_client_proxy.cpp. Signed-off-by: lixinpeng --- services/ims/input_event_client_proxy.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/services/ims/input_event_client_proxy.cpp b/services/ims/input_event_client_proxy.cpp index 900b1a5..422f30d 100644 --- a/services/ims/input_event_client_proxy.cpp +++ b/services/ims/input_event_client_proxy.cpp @@ -44,6 +44,7 @@ void InputEventClientProxy::ClientRequestHandle(int funcId, void* origin, IpcIo* void InputEventClientProxy::AddListener(const void* origin, IpcIo* req, IpcIo* reply) { + pthread_mutex_lock(&lock_); if (clientInfoMap_.size() >= MAX_CLIENT_SIZE) { pthread_mutex_unlock(&lock_); GRAPHIC_LOGE("Exceeded the maximum number!"); @@ -81,9 +82,7 @@ void InputEventClientProxy::RemoveListener(const void* origin, IpcIo* req, IpcIo pthread_mutex_lock(&lock_); if (clientInfoMap_.count(pid) > 0) { ReleaseSvc(clientInfoMap_[pid].svc); - pthread_mutex_lock(&lock_); clientInfoMap_.erase(pid); - pthread_mutex_unlock(&lock_); } pthread_mutex_unlock(&lock_); } -- Gitee