Made Client::close thread safe
This commit is contained in:
parent
0d8052dcb9
commit
76bf8942fd
2 changed files with 26 additions and 5 deletions
|
|
@ -40,7 +40,10 @@ namespace SimpleWeb {
|
|||
resolver.async_resolve(query, [this]
|
||||
(const boost::system::error_code &ec, boost::asio::ip::tcp::resolver::iterator it){
|
||||
if(!ec) {
|
||||
socket=std::unique_ptr<HTTPS>(new HTTPS(io_service, context));
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(socket_mutex);
|
||||
socket=std::unique_ptr<HTTPS>(new HTTPS(io_service, context));
|
||||
}
|
||||
|
||||
boost::asio::async_connect(socket->lowest_layer(), it, [this]
|
||||
(const boost::system::error_code &ec, boost::asio::ip::tcp::resolver::iterator /*it*/){
|
||||
|
|
@ -54,18 +57,21 @@ namespace SimpleWeb {
|
|||
if(timer)
|
||||
timer->cancel();
|
||||
if(ec) {
|
||||
std::lock_guard<std::mutex> lock(socket_mutex);
|
||||
this->socket=nullptr;
|
||||
throw boost::system::system_error(ec);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
std::lock_guard<std::mutex> lock(socket_mutex);
|
||||
this->socket=nullptr;
|
||||
throw boost::system::system_error(ec);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
std::lock_guard<std::mutex> lock(socket_mutex);
|
||||
socket=nullptr;
|
||||
throw boost::system::system_error(ec);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue