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.
This commit is contained in:
Tamás Bálint Misius 2023-02-01 19:26:59 +01:00
parent b7a6663e08
commit 85d492bad6
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2

View File

@ -1,6 +1,7 @@
#pragma once
#include "common/ExplicitSingleton.h"
#include "common/String.h"
#include <atomic>
#include <thread>
#include <vector>
#include <memory>
@ -36,8 +37,8 @@ namespace http
State state = ready;
std::mutex stateMx;
std::condition_variable stateCv;
int bytesTotal = 0;
int bytesDone = 0;
std::atomic<int> bytesTotal = 0;
std::atomic<int> bytesDone = 0;
int statusCode = 0;
ByteString responseData;
std::vector<ByteString> responseHeaders;