|
@@ -221,6 +221,8 @@ int CConnection::read(void * data, unsigned size)
|
|
|
|
|
|
CConnection::~CConnection()
|
|
|
{
|
|
|
+ close();
|
|
|
+
|
|
|
if(handler)
|
|
|
{
|
|
|
// ugly workaround to avoid self-join if last strong reference to shared_ptr that owns this class has been released in this very thread, e.g. on netpack processing
|
|
@@ -229,8 +231,6 @@ CConnection::~CConnection()
|
|
|
else
|
|
|
handler->detach();
|
|
|
}
|
|
|
-
|
|
|
- close();
|
|
|
}
|
|
|
|
|
|
template<class T>
|
|
@@ -246,6 +246,15 @@ void CConnection::close()
|
|
|
{
|
|
|
if(socket)
|
|
|
{
|
|
|
+ try
|
|
|
+ {
|
|
|
+ socket->shutdown(boost::asio::ip::tcp::socket::shutdown_receive);
|
|
|
+ }
|
|
|
+ catch (const boost::system::system_error & e)
|
|
|
+ {
|
|
|
+ logNetwork->error("error closing socket: %s", e.what());
|
|
|
+ }
|
|
|
+
|
|
|
socket->close();
|
|
|
socket.reset();
|
|
|
}
|