Skip to content
Snippets Groups Projects
Commit e2d7dbc2 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

proxy client: declare mutex before protected objects

parent 090da49f
No related branches found
No related tags found
No related merge requests found
...@@ -330,18 +330,6 @@ private: ...@@ -330,18 +330,6 @@ private:
//std::pair<std::string, std::string> serverHostService_; //std::pair<std::string, std::string> serverHostService_;
std::string pushClientId_; std::string pushClientId_;
/*
* ASIO I/O Context for sockets in httpClient_
* Note: Each context is used in one thread only
*/
asio::io_context httpContext_;
std::shared_ptr<http::Resolver> resolver_;
std::map<unsigned int /*id*/, std::shared_ptr<http::Request>> requests_;
/*
* Thread for executing the http io_context.run() blocking call
*/
std::thread httpClientThread_;
mutable std::mutex lockCurrentProxyInfos_; mutable std::mutex lockCurrentProxyInfos_;
NodeStatus statusIpv4_ {NodeStatus::Disconnected}; NodeStatus statusIpv4_ {NodeStatus::Disconnected};
NodeStatus statusIpv6_ {NodeStatus::Disconnected}; NodeStatus statusIpv6_ {NodeStatus::Disconnected};
...@@ -355,20 +343,32 @@ private: ...@@ -355,20 +343,32 @@ private:
// registred types // registred types
TypeStore types; TypeStore types;
/*
* ASIO I/O Context for sockets in httpClient_
* Note: Each context is used in one thread only
*/
asio::io_context httpContext_;
std::shared_ptr<http::Resolver> resolver_;
std::map<unsigned int /*id*/, std::shared_ptr<http::Request>> requests_;
/*
* Thread for executing the http io_context.run() blocking call
*/
std::thread httpClientThread_;
/** /**
* Store listen requests. * Store listen requests.
*/ */
struct ProxySearch; struct ProxySearch;
mutable std::mutex searchLock_;
size_t listenerToken_ {0}; size_t listenerToken_ {0};
std::map<InfoHash, ProxySearch> searches_; std::map<InfoHash, ProxySearch> searches_;
mutable std::mutex searchLock_;
/** /**
* Callbacks should be executed in the main thread. * Callbacks should be executed in the main thread.
*/ */
std::vector<std::function<void()>> callbacks_;
std::mutex lockCallbacks_; std::mutex lockCallbacks_;
std::vector<std::function<void()>> callbacks_;
Sp<InfoState> infoState_; Sp<InfoState> infoState_;
......
...@@ -981,6 +981,8 @@ DhtProxyClient::sendListen(const restinio::http_request_header_t header, ...@@ -981,6 +981,8 @@ DhtProxyClient::sendListen(const restinio::http_request_header_t header,
void void
DhtProxyClient::opFailed() DhtProxyClient::opFailed()
{ {
if (isDestroying_)
return;
if (logger_) if (logger_)
logger_->e("[proxy:client] proxy request failed"); logger_->e("[proxy:client] proxy request failed");
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment