代码优化 维护更多异常逻辑

Signed-off-by: Shenyx <shenyuxiang3@h-partners.com>
Change-Id: I40a5fb268f32842839a576423fee5ab36edd4ff5
This commit is contained in:
Shenyx 2024-11-19 20:12:22 +08:00
parent 52d5ade37c
commit e0ffeb4ee1
4 changed files with 10 additions and 4 deletions

View File

@ -440,7 +440,7 @@ size_t CUrlAdp::ReadCallback(char *buffer, size_t size, size_t nitems, void *arg
{
UPLOAD_HILOGD(UPLOAD_MODULE_FRAMEWORK, "size is %{public}zu, nitems is %{public}zu.", size, nitems);
FileData *fData = static_cast<FileData *>(arg);
if (!CheckCUrlAdp(fData) || ferror(fData->fp)) {
if (!CheckCUrlAdp(fData) || fData->fp == nullptr || ferror(fData->fp)) {
return CURL_READFUNC_ABORT;
}

View File

@ -62,6 +62,7 @@ private:
std::string host_;
std::string port_;
std::string exclusionList_;
std::mutex proxyMutex;
};
std::shared_ptr<SysNetProxySubscriber> SysNetProxyManager::subscriber_ = nullptr;

View File

@ -58,9 +58,10 @@ void SysNetProxyManager::SubscriberEvent()
REQUEST_HILOGE("Common Event is already subscribered.");
return;
}
g_proxyMutex.lock();
InitProxy(host_, port_, exclusionList_);
g_proxyMutex.unlock();
{
std::lock_guard<std::mutex> lock(proxyMutex);
InitProxy(host_, port_, exclusionList_);
}
OHOS::EventFwk::MatchingSkills matchingSkills;
matchingSkills.AddEvent(OHOS::EventFwk::CommonEventSupport::COMMON_EVENT_HTTP_PROXY_CHANGE);
OHOS::EventFwk::CommonEventSubscribeInfo subscribeInfo(matchingSkills);

View File

@ -309,6 +309,10 @@ void NotificationSubscriber::OnDied(){};
void NotificationSubscriber::OnResponse(
int32_t notificationId, sptr<Notification::NotificationButtonOption> buttonOption)
{
if (buttonOption == nullptr) {
REQUEST_HILOGE("buttonOption empty");
return;
}
if (buttonOption->GetButtonName() == "stop") {
this->_taskManager->pause_task(static_cast<uint32_t>(notificationId));
} else if (buttonOption->GetButtonName() == "start") {