From 0b1fecb27947aaf24501b820dd7176ba0212e82e Mon Sep 17 00:00:00 2001 From: hhchinasoft Date: Wed, 1 Dec 2021 16:25:59 +0800 Subject: [PATCH 1/2] code check clean --- .../js/napi/http/include/http_request.h | 5 --- frameworks/js/napi/http/src/http_napi.cpp | 6 +--- frameworks/js/napi/http/src/http_request.cpp | 35 +++---------------- frameworks/js/napi/socket/src/socket_napi.cpp | 30 ---------------- frameworks/js/napi/socket/src/tcp_socket.cpp | 1 - frameworks/js/napi/socket/src/udp_socket.cpp | 1 - 6 files changed, 6 insertions(+), 72 deletions(-) diff --git a/frameworks/js/napi/http/include/http_request.h b/frameworks/js/napi/http/include/http_request.h index 9041b8359..5baf4446b 100644 --- a/frameworks/js/napi/http/include/http_request.h +++ b/frameworks/js/napi/http/include/http_request.h @@ -54,22 +54,17 @@ public: void EmitHeader(HttpRequest *obj, const std::string &header); bool NativeRequest(HttpRequestOptionsContext *asyncContext); - void NativeDestroy(); - void NativeOn(); - void NativeOff(); private: static size_t OnWritingMemoryBody(const void *data, size_t size, size_t memBytes, void *userData) { ((std::string *)userData)->append((char *)data, 0, size * memBytes); - NETMGR_LOGD("OnWritingMemoryBody"); return size * memBytes; } static size_t OnWritingMemoryHeader(const void *data, size_t size, size_t memBytes, void *userData) { ((std::string *)userData)->append((char *)data, 0, size * memBytes); - NETMGR_LOGD("OnWritingMemoryHeader"); return size * memBytes; } diff --git a/frameworks/js/napi/http/src/http_napi.cpp b/frameworks/js/napi/http/src/http_napi.cpp index 4bccd3214..676ed49c0 100644 --- a/frameworks/js/napi/http/src/http_napi.cpp +++ b/frameworks/js/napi/http/src/http_napi.cpp @@ -144,7 +144,6 @@ static void RequestCallback(napi_env env, napi_status status, void *data) NapiUtil::SetPropertyArray(env, callbackValue, "cookie", cookie); } else { callbackValue = NapiUtil::CreateErrorMessage(env, "Request failed"); - NETMGR_LOGE("Request failed"); } if (asyncContext->callbackRef_ != nullptr) { napi_value callbackFunc = nullptr; @@ -162,10 +161,8 @@ static void RequestCallback(napi_env env, napi_status status, void *data) NAPI_CALL_RETURN_VOID(env, napi_delete_reference(env, asyncContext->callbackRef_)); } else if (asyncContext->deferred_ != nullptr) { if (asyncContext->resolved_) { - NETMGR_LOGD("Resolves deferred"); napi_resolve_deferred(env, asyncContext->deferred_, callbackValue); } else { - NETMGR_LOGD("Rejects deferred"); napi_reject_deferred(env, asyncContext->deferred_, callbackValue); } } @@ -206,7 +203,6 @@ napi_value Request(napi_env env, napi_callback_info info) NETMGR_LOGE("Http Request address is null"); return nullptr; } - NETMGR_LOGD("Http address is %{public}p", objectInfo); char url[OHOS::NetManagerStandard::URL_ARRAY_LENGTH] = {0}; size_t strLen = 0; @@ -353,7 +349,7 @@ napi_value On(napi_env env, napi_callback_info info) NAPI_CALL(env, napi_get_value_string_utf8( env, parameters[0], eventTypeChars, OHOS::NetManagerStandard::URL_ARRAY_LENGTH - 1, &strLen)); - NETMGR_LOGD("On Start napi_get_cb_info %{public}s, %{public}d", eventTypeChars, (int32_t)strLen); + napi_ref callbackRef = nullptr; if (paraCount == 2) { diff --git a/frameworks/js/napi/http/src/http_request.cpp b/frameworks/js/napi/http/src/http_request.cpp index 3a89966af..2fbefcade 100644 --- a/frameworks/js/napi/http/src/http_request.cpp +++ b/frameworks/js/napi/http/src/http_request.cpp @@ -35,7 +35,6 @@ HttpRequest::HttpRequest() HttpRequest::~HttpRequest() { curl_global_cleanup(); - NETMGR_LOGD("~HttpRequest"); } /* * Init curl all thread only @@ -48,7 +47,7 @@ bool HttpRequest::Initialize() } if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { - NETMGR_LOGD("curl_global_init function initialize failed"); + NETMGR_LOGD("curl global initialize failed"); return false; } return true; @@ -95,11 +94,11 @@ void HttpRequest::SetHeader(CURL *curl) void HttpRequest::SetOptionURL(CURL *curl, HttpRequestOptionsContext *asyncContext) { if (curl == nullptr || asyncContext == nullptr) { - NETMGR_LOGE("set curl url option, pointer address in null"); + NETMGR_LOGE("curl or asyncContext pointer address is empty"); return; } std::string url(asyncContext->GetUrl()); - NETMGR_LOGD("SetOptionURL : %{public}s", url.c_str()); + std::size_t index = url.find(URL_SEPARATOR); std::string caFile(asyncContext->GetCaFile()); bool isCaFile = IsCaFile(caFile); @@ -107,7 +106,7 @@ void HttpRequest::SetOptionURL(CURL *curl, HttpRequestOptionsContext *asyncConte int32_t offset = url.rfind(URL_SEPARATOR); std::string uri = url.substr(0, offset); std::string param = url.substr(offset + 1); - NETMGR_LOGD("final url : %{public}s, (%{public}s)", uri.c_str(), param.c_str()); + curl_easy_setopt(curl, CURLOPT_URL, uri.c_str()); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, param.c_str()); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true); @@ -115,10 +114,8 @@ void HttpRequest::SetOptionURL(CURL *curl, HttpRequestOptionsContext *asyncConte if (url.substr(0, URL_PREFIX_LENGTH) == std::string("https://")) { if (!isCaFile) { curl_easy_setopt(curl, CURLOPT_CAINFO, "/etc/ssl/cacert.pem"); - NETMGR_LOGD("Default CA filepath : /data/cacert.pem"); } else { curl_easy_setopt(curl, CURLOPT_CAINFO, caFile.c_str()); - NETMGR_LOGD("Input CA filepath : %{public}s", caFile.c_str()); } curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); @@ -179,8 +176,7 @@ bool HttpRequest::SetOptionForGet(CURL *curl, HttpRequestOptionsContext *asyncCo NETMGR_LOGE("set curl url option, pointer address in null"); return false; } - NETMGR_LOGD("begin to set option for get and encode final url %{public}s, extraData %{public}s", - asyncContext->GetUrl().c_str(), asyncContext->GetExtraData().c_str()); + std::string url(asyncContext->GetUrl()); if (!asyncContext->GetExtraData().empty()) { std::size_t index = url.find(URL_SEPARATOR); @@ -206,21 +202,18 @@ bool HttpRequest::SetOptionForGet(CURL *curl, HttpRequestOptionsContext *asyncCo int32_t offset = url.rfind(URL_SEPARATOR); std::string uri = url.substr(0, offset); std::string param = url.substr(offset + 1); - NETMGR_LOGD("final url : %{public}s, (%{public}s)", uri.c_str(), param.c_str()); curl_easy_setopt(curl, CURLOPT_URL, uri.c_str()); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, param.c_str()); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); } } - NETMGR_LOGD("final url : %{public}s, (%{public}d)", url.c_str(), (int32_t)url.length()); return true; } bool HttpRequest::GetCurlWriteData(HttpRequestOptionsContext *asyncContext) { - NETMGR_LOGD("GetCurlWriteData Begin"); if (asyncContext == nullptr) { return false; } @@ -264,12 +257,9 @@ bool HttpRequest::GetCurlWriteData(HttpRequestOptionsContext *asyncContext) void HttpRequest::EmitHeader(HttpRequest *obj, const std::string &header) { - NETMGR_LOGD("EmitHeader --------------- count = %{public}d", (int32_t)g_eventListenerList.size()); struct EventListener *eventListener = nullptr; for (std::list::iterator listenerIterator = g_eventListenerList.begin(); listenerIterator != g_eventListenerList.end(); ++listenerIterator) { - NETMGR_LOGD( - "EmitHeader --------------- obj %{public}p, %{public}p", obj, listenerIterator->httpRequestInfo_); if (listenerIterator->httpRequestInfo_ == obj) { struct EventListener eventListtmp = *listenerIterator; eventListener = &eventListtmp; @@ -308,21 +298,6 @@ bool HttpRequest::NativeRequest(HttpRequestOptionsContext *asyncContext) return GetCurlWriteData(asyncContext); } -void HttpRequest::NativeDestroy() -{ - NETMGR_LOGD("destroy start"); -} - -void HttpRequest::NativeOn() -{ - NETMGR_LOGD("on start"); -} - -void HttpRequest::NativeOff() -{ - NETMGR_LOGD("off start"); -} - bool HttpRequest::IsCaFile(const std::string &caFile) { if (caFile.empty()) { diff --git a/frameworks/js/napi/socket/src/socket_napi.cpp b/frameworks/js/napi/socket/src/socket_napi.cpp index caaaa99fa..001b07659 100644 --- a/frameworks/js/napi/socket/src/socket_napi.cpp +++ b/frameworks/js/napi/socket/src/socket_napi.cpp @@ -60,7 +60,6 @@ bool MatchSocketEventType(const std::string &type, const std::string &goalTypeSt int32_t GetSocketEventType(const std::string &type) { - NETMGR_LOGD("GetSocketEventType %{public}s", type.c_str()); if (MatchSocketEventType(type, MESSAGE_RECEIVE)) { return MESSAGE_SOCKET_STATE; } else if (MatchSocketEventType(type, LISTENING_RECEIVE)) { @@ -78,10 +77,8 @@ int32_t GetSocketEventType(const std::string &type) static void EmitUdpEvent(UDPSocket *obj, const std::string &type, const std::string &message) { int32_t eventType = GetSocketEventType(type); - NETMGR_LOGD("EmitUdpEvent UDP count = %{public}d", (int32_t)g_udpEventListenerList.size()); for (std::list::iterator listenerIterator = g_udpEventListenerList.begin(); listenerIterator != g_udpEventListenerList.end(); ++listenerIterator) { - NETMGR_LOGD("EmitUdpEvent obj %{public}p, %{public}p", obj, listenerIterator->udpSocket_); if (listenerIterator->udpSocket_ == obj && listenerIterator->eventType_ == eventType) { napi_env env = listenerIterator->env_; napi_handle_scope scope = nullptr; @@ -131,7 +128,6 @@ static void NativeUdpBind(napi_env env, void *data) std::string error("error"); EmitUdpEvent(asyncContext->udpRequestInfo_, "error", error); } - NETMGR_LOGD("NativeUdpBind errorCode:%{public}d", asyncContext->errorCode); } static void UdpBindCallback(napi_env env, napi_status status, void *data) @@ -245,7 +241,6 @@ static void NativeUdpSend(napi_env env, void *data) struct sockaddr_in addr; asyncContext->udpRequestInfo_->GetSocketInfo(addr, asyncContext); - NETMGR_LOGD("send data:%{public}s", asyncContext->data.c_str()); if (!asyncContext->isClose) { asyncContext->errorCode = asyncContext->udpRequestInfo_->UdpSend(asyncContext->socketfd, @@ -259,7 +254,6 @@ static void NativeUdpSend(napi_env env, void *data) std::string error("error"); EmitUdpEvent(asyncContext->udpRequestInfo_, "error", error); } - NETMGR_LOGD("NativeUdpSend errorCode:%{public}d", asyncContext->errorCode); } static void UdpSendCallback(napi_env env, napi_status status, void *data) @@ -318,7 +312,6 @@ static void NativeUdpClose(napi_env env, void *data) std::string error("error"); EmitUdpEvent(asyncContext->udpRequestInfo_, "error", error); } - NETMGR_LOGD("NativeUdpClose errorCode:%{public}d", asyncContext->errorCode); } static void UdpCloseCallback(napi_env env, napi_status status, void *data) @@ -530,9 +523,6 @@ napi_value UdpBind(napi_env env, napi_callback_info info) objectInfo->remInfo = *asyncContext; } - NETMGR_LOGD("GetSubscribeInfo parameterCount = %{public}d objectInfo = %{public}p, asyncContext = %{public}p", - (int32_t)parameterCount, objectInfo, asyncContext); - if (parameterCount == PARAMS_COUNT) { if (NapiUtil::MatchValueType(env, parameters[1], napi_function)) { NAPI_CALL(env, napi_create_reference(env, parameters[1], 1, &(asyncContext->callbackRef_))); @@ -766,7 +756,6 @@ napi_value UdpClose(napi_env env, napi_callback_info info) napi_value UdpGetState(napi_env env, napi_callback_info info) { - NETMGR_LOGD("udpGetState start"); std::size_t parameterCount = 1; napi_value parameters[1] = {0}; napi_value thisVar = nullptr; @@ -978,7 +967,6 @@ napi_value UdpOn(napi_env env, napi_callback_info info) if (eventType != NONE_EVENT_TYPE) { g_udpEventListenerList.push_back(listener); result = thisVar; - NETMGR_LOGD("ON Finish = %{public}d", (int32_t)g_udpEventListenerList.size()); } return thisVar; @@ -1031,7 +1019,6 @@ napi_value UdpOff(napi_env env, napi_callback_info info) return (listener.udpSocket_ == objectInfo && listener.eventType_ == eventType); }); result = thisVar; - NETMGR_LOGD("Off Finish"); } return thisVar; @@ -1040,10 +1027,8 @@ napi_value UdpOff(napi_env env, napi_callback_info info) static void EmitTcpEvent(TCPSocket *obj, const std::string &type, const std::string &message) { int32_t eventType = GetSocketEventType(type); - NETMGR_LOGD("EmitTcpEvent count = %{public}d", (int32_t)g_tcpEventListenerList.size()); for (std::list::iterator listenerIterator = g_tcpEventListenerList.begin(); listenerIterator != g_tcpEventListenerList.end(); ++listenerIterator) { - NETMGR_LOGD("EmitTcpEvent obj %{public}p, %{public}p", obj, listenerIterator->tcpSocket_); if (listenerIterator->tcpSocket_ == obj && listenerIterator->eventType_ == eventType) { napi_env env = listenerIterator->env_; napi_handle_scope scope = nullptr; @@ -1105,8 +1090,6 @@ static void NativeTcpBind(napi_env env, void *data) std::string error = asyncContext->errorString_; EmitTcpEvent(asyncContext->tcpSocket_, "error", error); } - - NETMGR_LOGD("NativeTcpBind errorCode:%{public}d", asyncContext->errorCode_); } static void TcpBindCallback(napi_env env, napi_status status, void *data) @@ -1185,8 +1168,6 @@ static void NativeTcpConnect(napi_env env, void *data) std::string error = asyncContext->errorString_; EmitTcpEvent(asyncContext->tcpSocket_, "error", error); } - - NETMGR_LOGD("NativeTcpConnect errorCode:%{public}d", asyncContext->errorCode_); } static void TcpConnectCallback(napi_env env, napi_status status, void *data) @@ -1239,7 +1220,6 @@ static void NativeTcpSend(napi_env env, void *data) struct sockaddr_in addr; asyncContext->tcpSocket_->GetSocketInfo(addr, asyncContext); - NETMGR_LOGD("send data:%{public}s", asyncContext->data.c_str()); if (!asyncContext->isClose) { asyncContext->errorCode_ = asyncContext->tcpSocket_->TcpSend(asyncContext->socketfd_, @@ -1251,8 +1231,6 @@ static void NativeTcpSend(napi_env env, void *data) std::string error = asyncContext->errorString_; EmitTcpEvent(asyncContext->tcpSocket_, "error", error); } - - NETMGR_LOGD("NativeTcpSend errorCode:%{public}d", asyncContext->errorCode_); } static void TcpSendCallback(napi_env env, napi_status status, void *data) @@ -1314,8 +1292,6 @@ static void NativeTcpClose(napi_env env, void *data) std::string error("error"); EmitTcpEvent(asyncContext->tcpSocket_, "error", error); } - - NETMGR_LOGD("NativeTcpClose errorCode:%{public}d", asyncContext->errorCode_); } static void TcpCloseCallback(napi_env env, napi_status status, void *data) @@ -1491,21 +1467,18 @@ static void NativeTcpSetExtraOptions(napi_env env, void *data) asyncContext->errorCode_ = asyncContext->tcpSocket_->TcpSetSockopt(asyncContext->socketfd_, SOL_SOCKET, SO_KEEPALIVE, (void *) &keepAlive, sizeof (keepAlive)); } - NETMGR_LOGD("NativeSetExtraOptionsSend keepAlive errorCode:%{public}d", asyncContext->errorCode_); bool OOBInline = asyncContext->tcpExtraOptions_.GetOOBInline(); if (OOBInline) { asyncContext->errorCode_ = asyncContext->tcpSocket_->TcpSetSockopt(asyncContext->socketfd_, SOL_SOCKET, SO_OOBINLINE, (void *) &OOBInline, sizeof (OOBInline)); } - NETMGR_LOGD("NativeSetExtraOptionsSend OOBInline errorCode:%{public}d", asyncContext->errorCode_); bool TCPNoDelay = asyncContext->tcpExtraOptions_.GetTCPNoDelay(); if (TCPNoDelay) { asyncContext->errorCode_ = asyncContext->tcpSocket_->TcpSetSockopt(asyncContext->socketfd_, IPPROTO_TCP, TCP_NODELAY, (void *) &TCPNoDelay, sizeof (TCPNoDelay)); } - NETMGR_LOGD("NativeSetExtraOptionsSend TCPNoDelay errorCode:%{public}d", asyncContext->errorCode_); bool on = asyncContext->tcpExtraOptions_.GetSocketLingerOn(); int32_t intLinger = asyncContext->tcpExtraOptions_.GetSocketLingerLinger(); @@ -1516,7 +1489,6 @@ static void NativeTcpSetExtraOptions(napi_env env, void *data) asyncContext->errorCode_ = asyncContext->tcpSocket_->TcpSetSockopt(asyncContext->socketfd_, SOL_SOCKET, SO_LINGER, (void *) &linger, sizeof (linger)); } - NETMGR_LOGD("NativeSetExtraOptionsSend errorCode:%{public}d", asyncContext->errorCode_); if (asyncContext->errorCode_ < 0) { std::string error = strerror(errno); @@ -2012,7 +1984,6 @@ napi_value TcpOn(napi_env env, napi_callback_info info) if (eventType != NONE_EVENT_TYPE) { g_tcpEventListenerList.push_back(listener); result = thisVar; - NETMGR_LOGD("ON Finish = %{public}d", (int32_t)g_tcpEventListenerList.size()); } return thisVar; @@ -2063,7 +2034,6 @@ napi_value TcpOff(napi_env env, napi_callback_info info) return (listener.tcpSocket_ == objectInfo && listener.eventType_ == eventType); }); result = thisVar; - NETMGR_LOGD("Off Finish"); } return thisVar; diff --git a/frameworks/js/napi/socket/src/tcp_socket.cpp b/frameworks/js/napi/socket/src/tcp_socket.cpp index 9f0377119..b22bb94ad 100644 --- a/frameworks/js/napi/socket/src/tcp_socket.cpp +++ b/frameworks/js/napi/socket/src/tcp_socket.cpp @@ -29,7 +29,6 @@ TCPSocket::TCPSocket(TcpBaseContext remInfo) TCPSocket::~TCPSocket() { TcpClose(this->tcpbaseContext_.socketfd_); - NETMGR_LOGD("~TCPSocket"); } void TCPSocket::GetJSParameter(napi_env &env, napi_value *parameters, TcpBaseContext*&asyncContext) diff --git a/frameworks/js/napi/socket/src/udp_socket.cpp b/frameworks/js/napi/socket/src/udp_socket.cpp index a72a23c43..7a0c79efb 100644 --- a/frameworks/js/napi/socket/src/udp_socket.cpp +++ b/frameworks/js/napi/socket/src/udp_socket.cpp @@ -28,7 +28,6 @@ UDPSocket::UDPSocket(Baseinfo remInfo) UDPSocket::~UDPSocket() { UdpClose(this->remInfo.socketfd); - NETMGR_LOGD("~UDPSocket"); } void UDPSocket::GetJSParameter(napi_env &env, napi_value *parameters, Baseinfo*&asyncContext) -- Gitee From 1807561d9230a10e39740658f8cdf835fe79a776 Mon Sep 17 00:00:00 2001 From: hhchinasoft Date: Wed, 1 Dec 2021 16:30:25 +0800 Subject: [PATCH 2/2] code check clean Signed-off-by: hhchinasoft --- .../js/napi/http/include/http_request.h | 5 --- frameworks/js/napi/http/src/http_napi.cpp | 6 +--- frameworks/js/napi/http/src/http_request.cpp | 35 +++---------------- frameworks/js/napi/socket/src/socket_napi.cpp | 30 ---------------- frameworks/js/napi/socket/src/tcp_socket.cpp | 1 - frameworks/js/napi/socket/src/udp_socket.cpp | 1 - 6 files changed, 6 insertions(+), 72 deletions(-) diff --git a/frameworks/js/napi/http/include/http_request.h b/frameworks/js/napi/http/include/http_request.h index 9041b8359..5baf4446b 100644 --- a/frameworks/js/napi/http/include/http_request.h +++ b/frameworks/js/napi/http/include/http_request.h @@ -54,22 +54,17 @@ public: void EmitHeader(HttpRequest *obj, const std::string &header); bool NativeRequest(HttpRequestOptionsContext *asyncContext); - void NativeDestroy(); - void NativeOn(); - void NativeOff(); private: static size_t OnWritingMemoryBody(const void *data, size_t size, size_t memBytes, void *userData) { ((std::string *)userData)->append((char *)data, 0, size * memBytes); - NETMGR_LOGD("OnWritingMemoryBody"); return size * memBytes; } static size_t OnWritingMemoryHeader(const void *data, size_t size, size_t memBytes, void *userData) { ((std::string *)userData)->append((char *)data, 0, size * memBytes); - NETMGR_LOGD("OnWritingMemoryHeader"); return size * memBytes; } diff --git a/frameworks/js/napi/http/src/http_napi.cpp b/frameworks/js/napi/http/src/http_napi.cpp index 4bccd3214..676ed49c0 100644 --- a/frameworks/js/napi/http/src/http_napi.cpp +++ b/frameworks/js/napi/http/src/http_napi.cpp @@ -144,7 +144,6 @@ static void RequestCallback(napi_env env, napi_status status, void *data) NapiUtil::SetPropertyArray(env, callbackValue, "cookie", cookie); } else { callbackValue = NapiUtil::CreateErrorMessage(env, "Request failed"); - NETMGR_LOGE("Request failed"); } if (asyncContext->callbackRef_ != nullptr) { napi_value callbackFunc = nullptr; @@ -162,10 +161,8 @@ static void RequestCallback(napi_env env, napi_status status, void *data) NAPI_CALL_RETURN_VOID(env, napi_delete_reference(env, asyncContext->callbackRef_)); } else if (asyncContext->deferred_ != nullptr) { if (asyncContext->resolved_) { - NETMGR_LOGD("Resolves deferred"); napi_resolve_deferred(env, asyncContext->deferred_, callbackValue); } else { - NETMGR_LOGD("Rejects deferred"); napi_reject_deferred(env, asyncContext->deferred_, callbackValue); } } @@ -206,7 +203,6 @@ napi_value Request(napi_env env, napi_callback_info info) NETMGR_LOGE("Http Request address is null"); return nullptr; } - NETMGR_LOGD("Http address is %{public}p", objectInfo); char url[OHOS::NetManagerStandard::URL_ARRAY_LENGTH] = {0}; size_t strLen = 0; @@ -353,7 +349,7 @@ napi_value On(napi_env env, napi_callback_info info) NAPI_CALL(env, napi_get_value_string_utf8( env, parameters[0], eventTypeChars, OHOS::NetManagerStandard::URL_ARRAY_LENGTH - 1, &strLen)); - NETMGR_LOGD("On Start napi_get_cb_info %{public}s, %{public}d", eventTypeChars, (int32_t)strLen); + napi_ref callbackRef = nullptr; if (paraCount == 2) { diff --git a/frameworks/js/napi/http/src/http_request.cpp b/frameworks/js/napi/http/src/http_request.cpp index 3a89966af..2fbefcade 100644 --- a/frameworks/js/napi/http/src/http_request.cpp +++ b/frameworks/js/napi/http/src/http_request.cpp @@ -35,7 +35,6 @@ HttpRequest::HttpRequest() HttpRequest::~HttpRequest() { curl_global_cleanup(); - NETMGR_LOGD("~HttpRequest"); } /* * Init curl all thread only @@ -48,7 +47,7 @@ bool HttpRequest::Initialize() } if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { - NETMGR_LOGD("curl_global_init function initialize failed"); + NETMGR_LOGD("curl global initialize failed"); return false; } return true; @@ -95,11 +94,11 @@ void HttpRequest::SetHeader(CURL *curl) void HttpRequest::SetOptionURL(CURL *curl, HttpRequestOptionsContext *asyncContext) { if (curl == nullptr || asyncContext == nullptr) { - NETMGR_LOGE("set curl url option, pointer address in null"); + NETMGR_LOGE("curl or asyncContext pointer address is empty"); return; } std::string url(asyncContext->GetUrl()); - NETMGR_LOGD("SetOptionURL : %{public}s", url.c_str()); + std::size_t index = url.find(URL_SEPARATOR); std::string caFile(asyncContext->GetCaFile()); bool isCaFile = IsCaFile(caFile); @@ -107,7 +106,7 @@ void HttpRequest::SetOptionURL(CURL *curl, HttpRequestOptionsContext *asyncConte int32_t offset = url.rfind(URL_SEPARATOR); std::string uri = url.substr(0, offset); std::string param = url.substr(offset + 1); - NETMGR_LOGD("final url : %{public}s, (%{public}s)", uri.c_str(), param.c_str()); + curl_easy_setopt(curl, CURLOPT_URL, uri.c_str()); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, param.c_str()); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true); @@ -115,10 +114,8 @@ void HttpRequest::SetOptionURL(CURL *curl, HttpRequestOptionsContext *asyncConte if (url.substr(0, URL_PREFIX_LENGTH) == std::string("https://")) { if (!isCaFile) { curl_easy_setopt(curl, CURLOPT_CAINFO, "/etc/ssl/cacert.pem"); - NETMGR_LOGD("Default CA filepath : /data/cacert.pem"); } else { curl_easy_setopt(curl, CURLOPT_CAINFO, caFile.c_str()); - NETMGR_LOGD("Input CA filepath : %{public}s", caFile.c_str()); } curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); @@ -179,8 +176,7 @@ bool HttpRequest::SetOptionForGet(CURL *curl, HttpRequestOptionsContext *asyncCo NETMGR_LOGE("set curl url option, pointer address in null"); return false; } - NETMGR_LOGD("begin to set option for get and encode final url %{public}s, extraData %{public}s", - asyncContext->GetUrl().c_str(), asyncContext->GetExtraData().c_str()); + std::string url(asyncContext->GetUrl()); if (!asyncContext->GetExtraData().empty()) { std::size_t index = url.find(URL_SEPARATOR); @@ -206,21 +202,18 @@ bool HttpRequest::SetOptionForGet(CURL *curl, HttpRequestOptionsContext *asyncCo int32_t offset = url.rfind(URL_SEPARATOR); std::string uri = url.substr(0, offset); std::string param = url.substr(offset + 1); - NETMGR_LOGD("final url : %{public}s, (%{public}s)", uri.c_str(), param.c_str()); curl_easy_setopt(curl, CURLOPT_URL, uri.c_str()); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, param.c_str()); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); } } - NETMGR_LOGD("final url : %{public}s, (%{public}d)", url.c_str(), (int32_t)url.length()); return true; } bool HttpRequest::GetCurlWriteData(HttpRequestOptionsContext *asyncContext) { - NETMGR_LOGD("GetCurlWriteData Begin"); if (asyncContext == nullptr) { return false; } @@ -264,12 +257,9 @@ bool HttpRequest::GetCurlWriteData(HttpRequestOptionsContext *asyncContext) void HttpRequest::EmitHeader(HttpRequest *obj, const std::string &header) { - NETMGR_LOGD("EmitHeader --------------- count = %{public}d", (int32_t)g_eventListenerList.size()); struct EventListener *eventListener = nullptr; for (std::list::iterator listenerIterator = g_eventListenerList.begin(); listenerIterator != g_eventListenerList.end(); ++listenerIterator) { - NETMGR_LOGD( - "EmitHeader --------------- obj %{public}p, %{public}p", obj, listenerIterator->httpRequestInfo_); if (listenerIterator->httpRequestInfo_ == obj) { struct EventListener eventListtmp = *listenerIterator; eventListener = &eventListtmp; @@ -308,21 +298,6 @@ bool HttpRequest::NativeRequest(HttpRequestOptionsContext *asyncContext) return GetCurlWriteData(asyncContext); } -void HttpRequest::NativeDestroy() -{ - NETMGR_LOGD("destroy start"); -} - -void HttpRequest::NativeOn() -{ - NETMGR_LOGD("on start"); -} - -void HttpRequest::NativeOff() -{ - NETMGR_LOGD("off start"); -} - bool HttpRequest::IsCaFile(const std::string &caFile) { if (caFile.empty()) { diff --git a/frameworks/js/napi/socket/src/socket_napi.cpp b/frameworks/js/napi/socket/src/socket_napi.cpp index caaaa99fa..001b07659 100644 --- a/frameworks/js/napi/socket/src/socket_napi.cpp +++ b/frameworks/js/napi/socket/src/socket_napi.cpp @@ -60,7 +60,6 @@ bool MatchSocketEventType(const std::string &type, const std::string &goalTypeSt int32_t GetSocketEventType(const std::string &type) { - NETMGR_LOGD("GetSocketEventType %{public}s", type.c_str()); if (MatchSocketEventType(type, MESSAGE_RECEIVE)) { return MESSAGE_SOCKET_STATE; } else if (MatchSocketEventType(type, LISTENING_RECEIVE)) { @@ -78,10 +77,8 @@ int32_t GetSocketEventType(const std::string &type) static void EmitUdpEvent(UDPSocket *obj, const std::string &type, const std::string &message) { int32_t eventType = GetSocketEventType(type); - NETMGR_LOGD("EmitUdpEvent UDP count = %{public}d", (int32_t)g_udpEventListenerList.size()); for (std::list::iterator listenerIterator = g_udpEventListenerList.begin(); listenerIterator != g_udpEventListenerList.end(); ++listenerIterator) { - NETMGR_LOGD("EmitUdpEvent obj %{public}p, %{public}p", obj, listenerIterator->udpSocket_); if (listenerIterator->udpSocket_ == obj && listenerIterator->eventType_ == eventType) { napi_env env = listenerIterator->env_; napi_handle_scope scope = nullptr; @@ -131,7 +128,6 @@ static void NativeUdpBind(napi_env env, void *data) std::string error("error"); EmitUdpEvent(asyncContext->udpRequestInfo_, "error", error); } - NETMGR_LOGD("NativeUdpBind errorCode:%{public}d", asyncContext->errorCode); } static void UdpBindCallback(napi_env env, napi_status status, void *data) @@ -245,7 +241,6 @@ static void NativeUdpSend(napi_env env, void *data) struct sockaddr_in addr; asyncContext->udpRequestInfo_->GetSocketInfo(addr, asyncContext); - NETMGR_LOGD("send data:%{public}s", asyncContext->data.c_str()); if (!asyncContext->isClose) { asyncContext->errorCode = asyncContext->udpRequestInfo_->UdpSend(asyncContext->socketfd, @@ -259,7 +254,6 @@ static void NativeUdpSend(napi_env env, void *data) std::string error("error"); EmitUdpEvent(asyncContext->udpRequestInfo_, "error", error); } - NETMGR_LOGD("NativeUdpSend errorCode:%{public}d", asyncContext->errorCode); } static void UdpSendCallback(napi_env env, napi_status status, void *data) @@ -318,7 +312,6 @@ static void NativeUdpClose(napi_env env, void *data) std::string error("error"); EmitUdpEvent(asyncContext->udpRequestInfo_, "error", error); } - NETMGR_LOGD("NativeUdpClose errorCode:%{public}d", asyncContext->errorCode); } static void UdpCloseCallback(napi_env env, napi_status status, void *data) @@ -530,9 +523,6 @@ napi_value UdpBind(napi_env env, napi_callback_info info) objectInfo->remInfo = *asyncContext; } - NETMGR_LOGD("GetSubscribeInfo parameterCount = %{public}d objectInfo = %{public}p, asyncContext = %{public}p", - (int32_t)parameterCount, objectInfo, asyncContext); - if (parameterCount == PARAMS_COUNT) { if (NapiUtil::MatchValueType(env, parameters[1], napi_function)) { NAPI_CALL(env, napi_create_reference(env, parameters[1], 1, &(asyncContext->callbackRef_))); @@ -766,7 +756,6 @@ napi_value UdpClose(napi_env env, napi_callback_info info) napi_value UdpGetState(napi_env env, napi_callback_info info) { - NETMGR_LOGD("udpGetState start"); std::size_t parameterCount = 1; napi_value parameters[1] = {0}; napi_value thisVar = nullptr; @@ -978,7 +967,6 @@ napi_value UdpOn(napi_env env, napi_callback_info info) if (eventType != NONE_EVENT_TYPE) { g_udpEventListenerList.push_back(listener); result = thisVar; - NETMGR_LOGD("ON Finish = %{public}d", (int32_t)g_udpEventListenerList.size()); } return thisVar; @@ -1031,7 +1019,6 @@ napi_value UdpOff(napi_env env, napi_callback_info info) return (listener.udpSocket_ == objectInfo && listener.eventType_ == eventType); }); result = thisVar; - NETMGR_LOGD("Off Finish"); } return thisVar; @@ -1040,10 +1027,8 @@ napi_value UdpOff(napi_env env, napi_callback_info info) static void EmitTcpEvent(TCPSocket *obj, const std::string &type, const std::string &message) { int32_t eventType = GetSocketEventType(type); - NETMGR_LOGD("EmitTcpEvent count = %{public}d", (int32_t)g_tcpEventListenerList.size()); for (std::list::iterator listenerIterator = g_tcpEventListenerList.begin(); listenerIterator != g_tcpEventListenerList.end(); ++listenerIterator) { - NETMGR_LOGD("EmitTcpEvent obj %{public}p, %{public}p", obj, listenerIterator->tcpSocket_); if (listenerIterator->tcpSocket_ == obj && listenerIterator->eventType_ == eventType) { napi_env env = listenerIterator->env_; napi_handle_scope scope = nullptr; @@ -1105,8 +1090,6 @@ static void NativeTcpBind(napi_env env, void *data) std::string error = asyncContext->errorString_; EmitTcpEvent(asyncContext->tcpSocket_, "error", error); } - - NETMGR_LOGD("NativeTcpBind errorCode:%{public}d", asyncContext->errorCode_); } static void TcpBindCallback(napi_env env, napi_status status, void *data) @@ -1185,8 +1168,6 @@ static void NativeTcpConnect(napi_env env, void *data) std::string error = asyncContext->errorString_; EmitTcpEvent(asyncContext->tcpSocket_, "error", error); } - - NETMGR_LOGD("NativeTcpConnect errorCode:%{public}d", asyncContext->errorCode_); } static void TcpConnectCallback(napi_env env, napi_status status, void *data) @@ -1239,7 +1220,6 @@ static void NativeTcpSend(napi_env env, void *data) struct sockaddr_in addr; asyncContext->tcpSocket_->GetSocketInfo(addr, asyncContext); - NETMGR_LOGD("send data:%{public}s", asyncContext->data.c_str()); if (!asyncContext->isClose) { asyncContext->errorCode_ = asyncContext->tcpSocket_->TcpSend(asyncContext->socketfd_, @@ -1251,8 +1231,6 @@ static void NativeTcpSend(napi_env env, void *data) std::string error = asyncContext->errorString_; EmitTcpEvent(asyncContext->tcpSocket_, "error", error); } - - NETMGR_LOGD("NativeTcpSend errorCode:%{public}d", asyncContext->errorCode_); } static void TcpSendCallback(napi_env env, napi_status status, void *data) @@ -1314,8 +1292,6 @@ static void NativeTcpClose(napi_env env, void *data) std::string error("error"); EmitTcpEvent(asyncContext->tcpSocket_, "error", error); } - - NETMGR_LOGD("NativeTcpClose errorCode:%{public}d", asyncContext->errorCode_); } static void TcpCloseCallback(napi_env env, napi_status status, void *data) @@ -1491,21 +1467,18 @@ static void NativeTcpSetExtraOptions(napi_env env, void *data) asyncContext->errorCode_ = asyncContext->tcpSocket_->TcpSetSockopt(asyncContext->socketfd_, SOL_SOCKET, SO_KEEPALIVE, (void *) &keepAlive, sizeof (keepAlive)); } - NETMGR_LOGD("NativeSetExtraOptionsSend keepAlive errorCode:%{public}d", asyncContext->errorCode_); bool OOBInline = asyncContext->tcpExtraOptions_.GetOOBInline(); if (OOBInline) { asyncContext->errorCode_ = asyncContext->tcpSocket_->TcpSetSockopt(asyncContext->socketfd_, SOL_SOCKET, SO_OOBINLINE, (void *) &OOBInline, sizeof (OOBInline)); } - NETMGR_LOGD("NativeSetExtraOptionsSend OOBInline errorCode:%{public}d", asyncContext->errorCode_); bool TCPNoDelay = asyncContext->tcpExtraOptions_.GetTCPNoDelay(); if (TCPNoDelay) { asyncContext->errorCode_ = asyncContext->tcpSocket_->TcpSetSockopt(asyncContext->socketfd_, IPPROTO_TCP, TCP_NODELAY, (void *) &TCPNoDelay, sizeof (TCPNoDelay)); } - NETMGR_LOGD("NativeSetExtraOptionsSend TCPNoDelay errorCode:%{public}d", asyncContext->errorCode_); bool on = asyncContext->tcpExtraOptions_.GetSocketLingerOn(); int32_t intLinger = asyncContext->tcpExtraOptions_.GetSocketLingerLinger(); @@ -1516,7 +1489,6 @@ static void NativeTcpSetExtraOptions(napi_env env, void *data) asyncContext->errorCode_ = asyncContext->tcpSocket_->TcpSetSockopt(asyncContext->socketfd_, SOL_SOCKET, SO_LINGER, (void *) &linger, sizeof (linger)); } - NETMGR_LOGD("NativeSetExtraOptionsSend errorCode:%{public}d", asyncContext->errorCode_); if (asyncContext->errorCode_ < 0) { std::string error = strerror(errno); @@ -2012,7 +1984,6 @@ napi_value TcpOn(napi_env env, napi_callback_info info) if (eventType != NONE_EVENT_TYPE) { g_tcpEventListenerList.push_back(listener); result = thisVar; - NETMGR_LOGD("ON Finish = %{public}d", (int32_t)g_tcpEventListenerList.size()); } return thisVar; @@ -2063,7 +2034,6 @@ napi_value TcpOff(napi_env env, napi_callback_info info) return (listener.tcpSocket_ == objectInfo && listener.eventType_ == eventType); }); result = thisVar; - NETMGR_LOGD("Off Finish"); } return thisVar; diff --git a/frameworks/js/napi/socket/src/tcp_socket.cpp b/frameworks/js/napi/socket/src/tcp_socket.cpp index 9f0377119..b22bb94ad 100644 --- a/frameworks/js/napi/socket/src/tcp_socket.cpp +++ b/frameworks/js/napi/socket/src/tcp_socket.cpp @@ -29,7 +29,6 @@ TCPSocket::TCPSocket(TcpBaseContext remInfo) TCPSocket::~TCPSocket() { TcpClose(this->tcpbaseContext_.socketfd_); - NETMGR_LOGD("~TCPSocket"); } void TCPSocket::GetJSParameter(napi_env &env, napi_value *parameters, TcpBaseContext*&asyncContext) diff --git a/frameworks/js/napi/socket/src/udp_socket.cpp b/frameworks/js/napi/socket/src/udp_socket.cpp index a72a23c43..7a0c79efb 100644 --- a/frameworks/js/napi/socket/src/udp_socket.cpp +++ b/frameworks/js/napi/socket/src/udp_socket.cpp @@ -28,7 +28,6 @@ UDPSocket::UDPSocket(Baseinfo remInfo) UDPSocket::~UDPSocket() { UdpClose(this->remInfo.socketfd); - NETMGR_LOGD("~UDPSocket"); } void UDPSocket::GetJSParameter(napi_env &env, napi_value *parameters, Baseinfo*&asyncContext) -- Gitee