Improved way sockets are closed.

Not 100% sure this is allowed by boost::asio thought a code inspection suggest it does as it is ignoring the error it gets on close.
This commit is contained in:
eelke 2018-04-08 09:06:05 +02:00
parent 61645d44ac
commit 5e83094e6a

View file

@ -40,6 +40,7 @@ void ASyncDBConnection::setupConnection(const ConnectionConfig &config)
// auto start = std::chrono::steady_clock::now();
if (ok && m_connection.status() != CONNECTION_BAD) {
auto sock_handle = m_connection.socket();
m_asioSock.assign(ip::tcp::v4(), sock_handle);
m_asioSock.non_blocking(true);
@ -99,7 +100,9 @@ void ASyncDBConnection::closeConnection()
m_canceller.cancel(nullptr);
}
if (m_state != State::NotConnected) {
m_asioSock.close();
// Do not really want to close it before libpq is finished with it
// However explicitly is the destroctor doing the right thing?
//m_asioSock.close();
m_connection.close();
}
doStateCallback(State::NotConnected);