Skip to content
This repository has been archived by the owner on Jun 12, 2018. It is now read-only.

Commit

Permalink
Fixes #91: added timeout on Client's async_connect
Browse files Browse the repository at this point in the history
  • Loading branch information
eidheim committed Dec 11, 2016
1 parent 14d848b commit dc7762e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion client_http.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,11 @@ namespace SimpleWeb {
socket=std::unique_ptr<HTTP>(new HTTP(io_service));
}

boost::asio::async_connect(*socket, it, [this]
auto timer=get_timeout_timer();
boost::asio::async_connect(*socket, it, [this, timer]
(const boost::system::error_code &ec, boost::asio::ip::tcp::resolver::iterator /*it*/){
if(timer)
timer->cancel();
if(!ec) {
boost::asio::ip::tcp::no_delay option(true);
this->socket->set_option(option);
Expand Down
5 changes: 4 additions & 1 deletion client_https.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ namespace SimpleWeb {
socket=std::unique_ptr<HTTPS>(new HTTPS(io_service, context));
}

boost::asio::async_connect(socket->lowest_layer(), it, [this]
auto timer=get_timeout_timer();
boost::asio::async_connect(socket->lowest_layer(), it, [this, timer]
(const boost::system::error_code &ec, boost::asio::ip::tcp::resolver::iterator /*it*/){
if(timer)
timer->cancel();
if(!ec) {
boost::asio::ip::tcp::no_delay option(true);
this->socket->lowest_layer().set_option(option);
Expand Down

0 comments on commit dc7762e

Please sign in to comment.