From 818f5be1e97b0d7eb36f46f2641f23740f23025c Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 20 Nov 2021 17:44:55 +0100 Subject: [PATCH] Fix crash on startup. --- main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index e4aa2e1..84188d9 100644 --- a/main.cpp +++ b/main.cpp @@ -112,13 +112,17 @@ void download_posts(Database *db, const String &site) { trantor::EventLoop *loop; std::thread t([&loop]() { loop = new trantor::EventLoop(); loop->loop(); delete loop; loop = nullptr; }); + while (loop == nullptr) { + //todo sleep + } + HttpClientPtr http_client = drogon::HttpClient::newHttpClient("http://127.0.0.1:8080/", loop); HttpRequestPtr request = drogon::HttpRequest::newHttpRequest(); request->setMethod(drogon::HttpMethod::Get); request->setPath(last_url); - http_client->sendRequest(request); + http_client->sendRequest(request, [](ReqResult res, const HttpResponsePtr &resptr){ RLOG_ERR("test\n"); }); while (true) { //todo remove