ASyncDBConnectionThread now reports back when it looses the connection
This commit is contained in:
parent
d6709a1dea
commit
b87f587a40
1 changed files with 11 additions and 3 deletions
|
|
@ -7,6 +7,7 @@
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <WinSock2.h>
|
#include <WinSock2.h>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
|
@ -322,6 +323,7 @@ void ASyncDBConnectionThread::doNewCommand()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::string error = m_connection.getErrorMessage();
|
std::string error = m_connection.getErrorMessage();
|
||||||
|
qDebug() << "Error sending query " << QString::fromStdString(error);
|
||||||
// todo: need to report the error
|
// todo: need to report the error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -353,12 +355,17 @@ bool ASyncDBConnectionThread::consumeResultInput()
|
||||||
else {
|
else {
|
||||||
// error during consume
|
// error during consume
|
||||||
auto error_msg = m_connection.getErrorMessage();
|
auto error_msg = m_connection.getErrorMessage();
|
||||||
|
qDebug() << "error while communicating with server " << QString::fromStdString(error_msg);
|
||||||
|
doStateCallback(ASyncDBConnection::State::NotConnected);
|
||||||
|
finished = true;
|
||||||
|
stop();
|
||||||
}
|
}
|
||||||
return finished;
|
return finished;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASyncDBConnectionThread::waitForResult()
|
void ASyncDBConnectionThread::waitForResult()
|
||||||
{
|
{
|
||||||
|
#if false
|
||||||
int sock = m_connection.socket();
|
int sock = m_connection.socket();
|
||||||
|
|
||||||
fd_set readfds;
|
fd_set readfds;
|
||||||
|
|
@ -381,7 +388,8 @@ void ASyncDBConnectionThread::waitForResult()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#if false
|
#else
|
||||||
|
SOCKET sock = static_cast<SOCKET>(m_connection.socket());
|
||||||
Win32Event socket_event(Win32Event::Reset::Manual, Win32Event::Initial::Clear);
|
Win32Event socket_event(Win32Event::Reset::Manual, Win32Event::Initial::Clear);
|
||||||
|
|
||||||
long fd = FD_READ | FD_CLOSE;
|
long fd = FD_READ | FD_CLOSE;
|
||||||
|
|
@ -392,7 +400,7 @@ void ASyncDBConnectionThread::waitForResult()
|
||||||
|
|
||||||
WaitHandleList whl;
|
WaitHandleList whl;
|
||||||
auto wait_result_socket = whl.add(socket_event);
|
auto wait_result_socket = whl.add(socket_event);
|
||||||
//auto wait_result_stop = whl.add(m_stopEvent);
|
auto wait_result_stop = whl.add(m_stopEvent);
|
||||||
|
|
||||||
DWORD res = MsgWaitForMultipleObjectsEx(
|
DWORD res = MsgWaitForMultipleObjectsEx(
|
||||||
whl.count(), // _In_ DWORD nCount,
|
whl.count(), // _In_ DWORD nCount,
|
||||||
|
|
@ -414,7 +422,7 @@ void ASyncDBConnectionThread::waitForResult()
|
||||||
if (res == wait_result_stop) {
|
if (res == wait_result_stop) {
|
||||||
// Send cancel, close connection and terminate thread
|
// Send cancel, close connection and terminate thread
|
||||||
cancel();
|
cancel();
|
||||||
doStateCallback(State::Terminating);
|
doStateCallback(ASyncDBConnection::State::Terminating);
|
||||||
finished = true;
|
finished = true;
|
||||||
}
|
}
|
||||||
} // end while
|
} // end while
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue