File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -229,13 +229,18 @@ class DPP_EXPORT http_request {
229229 /* *
230230 * @brief True if request has been made.
231231 */
232- bool completed;
232+ std::atomic< bool > completed;
233233
234234 /* *
235235 * @brief True for requests that are not going to discord (rate limits code skipped).
236236 */
237237 bool non_discord;
238238
239+ /* *
240+ * @brief Client mutex
241+ */
242+ std::mutex cli_mutex;
243+
239244 /* *
240245 * @brief HTTPS client
241246 */
Original file line number Diff line number Diff line change @@ -57,8 +57,11 @@ bool cluster::stop_timer(timer t) {
5757void cluster::tick_timers () {
5858 time_t now = time (nullptr );
5959
60- if (next_timer.empty ()) {
61- return ;
60+ {
61+ std::lock_guard<std::mutex> l (timer_guard);
62+ if (next_timer.empty ()) {
63+ return ;
64+ }
6265 }
6366 do {
6467 timer_t cur_timer;
Original file line number Diff line number Diff line change @@ -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 ()));
Original file line number Diff line number Diff line change @@ -135,6 +135,7 @@ struct DPP_EXPORT socket_engine_epoll : public socket_engine_base {
135135
136136 if ((eh->flags & WANT_DELETION ) != 0L ) {
137137 remove_socket (fd);
138+ std::lock_guard<std::shared_mutex> lg (this ->fds_mutex );
138139 fds.erase (fd);
139140 }
140141 }
You can’t perform that action at this time.
0 commit comments