From 705509c33b6714c89cc6da2fb06e8c6fb6ebf10f Mon Sep 17 00:00:00 2001 From: maosiping Date: Sat, 31 Aug 2024 11:36:32 +0800 Subject: [PATCH] fix web crash Signed-off-by: maosiping --- .../websocket_exec/include/websocket_exec.h | 2 -- .../websocket_exec/src/websocket_exec.cpp | 14 ++------------ 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/frameworks/js/napi/websocket/websocket_exec/include/websocket_exec.h b/frameworks/js/napi/websocket/websocket_exec/include/websocket_exec.h index 0e0c7072..0bbc08de 100644 --- a/frameworks/js/napi/websocket/websocket_exec/include/websocket_exec.h +++ b/frameworks/js/napi/websocket/websocket_exec/include/websocket_exec.h @@ -44,8 +44,6 @@ private: static bool ParseUrl(ConnectContext *context, char *prefix, size_t prefixLen, char *address, size_t addressLen, char *path, size_t pathLen, int *port); - static void RunService(EventManager *manager); - static int RaiseError(EventManager *manager, uint32_t httpResponse); static int HttpDummy(lws *wsi, lws_callback_reasons reason, void *user, void *in, size_t len); diff --git a/frameworks/js/napi/websocket/websocket_exec/src/websocket_exec.cpp b/frameworks/js/napi/websocket/websocket_exec/src/websocket_exec.cpp index a7accca8..3d6791b8 100644 --- a/frameworks/js/napi/websocket/websocket_exec/src/websocket_exec.cpp +++ b/frameworks/js/napi/websocket/websocket_exec/src/websocket_exec.cpp @@ -282,19 +282,10 @@ bool WebSocketExec::ParseUrl(ConnectContext *context, char *protocol, size_t pro return true; } -void WebSocketExec::RunService(EventManager *manager) +void RunService(UserData *userData) { NETSTACK_LOGI("websocket run service start"); int res = 0; - if (!EventManager::IsManagerValid(manager)) { - NETSTACK_LOGE("manager is invalid"); - return; - } - if (manager == nullptr || manager->GetData() == nullptr) { - NETSTACK_LOGE("RunService para error"); - return; - } - auto userData = reinterpret_cast(manager->GetData()); lws_context *context = userData->GetContext(); if (context == nullptr) { NETSTACK_LOGE("context is null"); @@ -306,7 +297,6 @@ void WebSocketExec::RunService(EventManager *manager) lws_context_destroy(context); userData->SetContext(nullptr); delete userData; - manager->SetData(nullptr); NETSTACK_LOGI("websocket run service end"); } @@ -823,7 +813,7 @@ bool WebSocketExec::ExecConnect(ConnectContext *context) delete userData; return false; } - std::thread serviceThread(RunService, manager); + std::thread serviceThread(RunService, userData); #if defined(MAC_PLATFORM) || defined(IOS_PLATFORM) pthread_setname_np(WEBSOCKET_CLIENT_THREAD_RUN);