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 else
{ {
std::string msg = ec.message();
std::cout << msg << std::endl;
lowerSocket().close(); lowerSocket().close();
} }
@ -180,11 +182,15 @@ private:
} }
else else
{ {
std::string msg = ec.message();
std::cout << msg << std::endl;
lowerSocket().close(); lowerSocket().close();
} }
} }
else else
{ {
std::string msg = ec.message();
std::cout << msg << std::endl;
lowerSocket().close(); lowerSocket().close();
} }
}); });
@ -211,6 +217,8 @@ private:
} }
else else
{ {
std::string msg = ec.message();
std::cout << msg << std::endl;
lowerSocket().close(); lowerSocket().close();
} }
}); });
@ -237,7 +245,10 @@ private:
} }
else else
{ {
std::string msg = ec.message();
std::cout << msg << std::endl;
lowerSocket().close(); lowerSocket().close();
} }
}); });
} }
@ -275,11 +286,15 @@ private:
} }
else else
{ {
std::string msg = ec.message();
std::cout << msg << std::endl;
lowerSocket().close(); lowerSocket().close();
} }
} }
else else
{ {
std::string msg = ec.message();
std::cout << msg << std::endl;
lowerSocket().close(); 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 else
{ {
std::string msg = ec.message(); 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 else
{ {
std::string msg = ec.message(); std::string msg = ec.message();
@ -682,10 +715,11 @@ class ProxyServer
public: public:
ProxyServer(boost::asio::io_service& inIoService, ProxyServer(boost::asio::io_service& inIoService,
const boost::asio::ip::tcp::endpoint& endpoint, const boost::asio::ip::tcp::endpoint& endpoint,
boost::asio::ssl::context& sslContext) boost::asio::ssl::context& inSslContext)
: ioService(inIoService) : ioService(inIoService)
, acceptor(inIoService, endpoint) , acceptor(inIoService, endpoint)
, socket(std::make_shared<ssl_socket>(inIoService, sslContext)) , socket(std::make_shared<ssl_socket>(inIoService, inSslContext))
, sslContext(inSslContext)
{ {
doAccept(); doAccept();
} }
@ -703,6 +737,8 @@ private:
counter++; counter++;
socket = std::make_shared<ssl_socket>(ioService, sslContext);
doAccept(); doAccept();
}); });
} }
@ -712,6 +748,8 @@ private:
boost::asio::ip::tcp::acceptor acceptor; boost::asio::ip::tcp::acceptor acceptor;
std::shared_ptr<ssl_socket> socket; std::shared_ptr<ssl_socket> socket;
boost::asio::ssl::context& sslContext;
//std::map<size_t, ProxySession> proxySessionMap; //std::map<size_t, ProxySession> proxySessionMap;
size_t counter = 0; size_t counter = 0;
@ -728,7 +766,6 @@ int main()
boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::tcp::v4(), 8043); boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::tcp::v4(), 8043);
boost::asio::ssl::context sslContext(boost::asio::ssl::context::sslv23); boost::asio::ssl::context sslContext(boost::asio::ssl::context::sslv23);
sslContext.set_options( sslContext.set_options(