From 5e83094e6a6d469ee154fed949fffd2f25dc4a10 Mon Sep 17 00:00:00 2001 From: eelke Date: Sun, 8 Apr 2018 09:06:05 +0200 Subject: [PATCH] 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. --- pglablib/ASyncDBConnection.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pglablib/ASyncDBConnection.cpp b/pglablib/ASyncDBConnection.cpp index a8ae04e..3b93ce8 100644 --- a/pglablib/ASyncDBConnection.cpp +++ b/pglablib/ASyncDBConnection.cpp @@ -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);