!1516 fix http_crash

Merge pull request !1516 from maosiping/master
This commit is contained in:
openharmony_ci 2024-08-31 11:33:29 +00:00 committed by Gitee
commit ece1976f3e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 6 additions and 1 deletions

View File

@ -19,6 +19,7 @@
#include <atomic>
#include <memory>
#include <mutex>
#include <thread>
#include "curl/curl.h"
@ -42,6 +43,7 @@ private:
std::atomic_bool stop_ = false;
std::once_flag init_;
int sleepTimeoutMs_;
std::thread workThread_;
std::shared_ptr<HttpOverCurl::ThreadSafeStorage<RequestInfo *>> incomingQueue_;
};

View File

@ -33,6 +33,9 @@ EpollRequestHandler::EpollRequestHandler(int sleepTimeoutMs)
EpollRequestHandler::~EpollRequestHandler()
{
stop_ = true;
if (workThread_.joinable()) {
workThread_.join();
}
}
void EpollRequestHandler::Process(CURL *easyHandle, const TransferStartedCallback &startedCallback,
@ -50,7 +53,7 @@ void EpollRequestHandler::Process(CURL *easyHandle, const TransferStartedCallbac
#endif
WorkingThread();
};
auto workThread_ = std::thread(f);
workThread_ = std::thread(f);
workThread_.detach();
};