Fixes #91: added timeout on Client's async_connect

This commit is contained in:
eidheim 2016-12-11 10:53:33 +01:00
commit dc7762e63b
2 changed files with 8 additions and 2 deletions

View file

@ -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);

View file

@ -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);