Fixing bug with connection closed unexpectedly

This commit is contained in:
Vladislav Khorev 2017-08-07 05:26:32 +03:00
parent ae93b73f27
commit 6a7ced5a80

View File

@ -136,6 +136,8 @@ private:
}
else
{
std::string msg = ec.message();
std::cout << msg << std::endl;
lowerSocket().close();
}
@ -180,11 +182,15 @@ private:
}
else
{
std::string msg = ec.message();
std::cout << msg << std::endl;
lowerSocket().close();
}
}
else
{
std::string msg = ec.message();
std::cout << msg << std::endl;
lowerSocket().close();
}
});
@ -211,6 +217,8 @@ private:
}
else
{
std::string msg = ec.message();
std::cout << msg << std::endl;
lowerSocket().close();
}
});
@ -237,7 +245,10 @@ private:
}
else
{
std::string msg = ec.message();
std::cout << msg << std::endl;
lowerSocket().close();
}
});
}
@ -275,11 +286,15 @@ private:
}
else
{
std::string msg = ec.message();
std::cout << msg << std::endl;
lowerSocket().close();
}
}
else
{
std::string msg = ec.message();
std::cout << msg << std::endl;
lowerSocket().close();
}
});
@ -610,6 +625,15 @@ private:
}
});
}
else if (ec == boost::asio::error::eof)
{
std::cout << "transferDataForward read end of file" << std::endl;
if (length > 0)
{
std::cout << "but length is positive" << std::endl;
}
return;
}
else
{
std::string msg = ec.message();
@ -654,6 +678,15 @@ private:
}
});
}
else if (ec == boost::asio::error::eof)
{
std::cout << "transferDataBackward read end of file" << std::endl;
if (length > 0)
{
std::cout << "but length is positive" << std::endl;
}
return;
}
else
{
std::string msg = ec.message();
@ -682,10 +715,11 @@ class ProxyServer
public:
ProxyServer(boost::asio::io_service& inIoService,
const boost::asio::ip::tcp::endpoint& endpoint,
boost::asio::ssl::context& sslContext)
boost::asio::ssl::context& inSslContext)
: ioService(inIoService)
, acceptor(inIoService, endpoint)
, socket(std::make_shared<ssl_socket>(inIoService, sslContext))
, socket(std::make_shared<ssl_socket>(inIoService, inSslContext))
, sslContext(inSslContext)
{
doAccept();
}
@ -703,6 +737,8 @@ private:
counter++;
socket = std::make_shared<ssl_socket>(ioService, sslContext);
doAccept();
});
}
@ -712,6 +748,8 @@ private:
boost::asio::ip::tcp::acceptor acceptor;
std::shared_ptr<ssl_socket> socket;
boost::asio::ssl::context& sslContext;
//std::map<size_t, ProxySession> proxySessionMap;
size_t counter = 0;
@ -728,7 +766,6 @@ int main()
boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::tcp::v4(), 8043);
boost::asio::ssl::context sslContext(boost::asio::ssl::context::sslv23);
sslContext.set_options(