From 85d492bad6a7d5a0c74adcd707f68bf91b547978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20B=C3=A1lint=20Misius?= Date: Wed, 1 Feb 2023 19:26:59 +0100 Subject: [PATCH] Make request progress variables atomic These are the only bit of shared state between the Request user thread and RequestManager that aren't covered by RequestHandle::stateMx. The problem was that they were not covered by anything, which meant that they were not guaranteed to be coherent between threads. --- src/client/http/requestmanager/RequestManager.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/client/http/requestmanager/RequestManager.h b/src/client/http/requestmanager/RequestManager.h index 88b45199a..c7cbb1ee9 100644 --- a/src/client/http/requestmanager/RequestManager.h +++ b/src/client/http/requestmanager/RequestManager.h @@ -1,6 +1,7 @@ #pragma once #include "common/ExplicitSingleton.h" #include "common/String.h" +#include #include #include #include @@ -36,8 +37,8 @@ namespace http State state = ready; std::mutex stateMx; std::condition_variable stateCv; - int bytesTotal = 0; - int bytesDone = 0; + std::atomic bytesTotal = 0; + std::atomic bytesDone = 0; int statusCode = 0; ByteString responseData; std::vector responseHeaders;