@@ -225,7 +225,7 @@ http_request_completion_t http_request::run(request_concurrency_queue* processor
225225 }
226226 http_connect_info hci = https_client::get_host_info (_host);
227227 try {
228- cli = std::make_unique<https_client>(
228+ std::unique_ptr<https_client> tmp = std::make_unique<https_client>(
229229 owner,
230230 hci.hostname ,
231231 hci.port ,
@@ -286,6 +286,10 @@ http_request_completion_t http_request::run(request_concurrency_queue* processor
286286 });
287287 }
288288 );
289+ {
290+ std::lock_guard<std::mutex> client (this ->cli_mutex );
291+ cli = std::move (tmp);
292+ }
289293 }
290294 catch (const std::exception& e) {
291295 owner->log (ll_error, " HTTP(S) error on " + hci.scheme + " connection to " + hci.hostname + " :" + std::to_string (hci.port ) + " : " + std::string (e.what ()));
@@ -313,7 +317,7 @@ request_concurrency_queue::request_concurrency_queue(class cluster* owner, class
313317 tick_and_deliver_requests (in_index);
314318 /* Clear pending removals in the removals queue */
315319 if (time (nullptr ) % 90 == 0 ) {
316- std::scoped_lock lock1{in_mutex };
320+ std::scoped_lock lock1{rem_mutex };
317321 for (auto it = removals.cbegin (); it != removals.cend ();) {
318322 if ((*it)->is_completed ()) {
319323 it = removals.erase (it);
@@ -404,7 +408,8 @@ void request_concurrency_queue::tick_and_deliver_requests(uint32_t index)
404408 std::unique_ptr<http_request> rq;
405409 {
406410 /* Find the owned pointer in requests_in */
407- std::scoped_lock lock1{in_mutex};
411+ std::scoped_lock requests_in_lock{in_mutex};
412+ std::scoped_lock removals_queue_lock{rem_mutex};
408413
409414 const std::string &key = request_view->endpoint ;
410415 auto [begin, end] = std::equal_range (requests_in.begin (), requests_in.end (), key, compare_request{});
0 commit comments