Better handling of empty query's.

This commit is contained in:
eelke 2019-12-18 19:35:17 +01:00
parent 47b3ea83e9
commit 23165d77c8

View file

@ -310,7 +310,6 @@ void ASyncDBConnectionThread::doNewCommand()
// get command from top of queue (but leave it in the queue, we need the callback) // get command from top of queue (but leave it in the queue, we need the callback)
if (! m_commandQueue.m_queue.empty()) { if (! m_commandQueue.m_queue.empty()) {
const Command &command = m_commandQueue.m_queue.front(); const Command &command = m_commandQueue.m_queue.front();
if (!command.command.empty()) {
bool query_send = false; bool query_send = false;
if (command.params.empty()) if (command.params.empty())
query_send = m_connection.sendQuery(command.command.c_str()); query_send = m_connection.sendQuery(command.command.c_str());
@ -326,7 +325,6 @@ void ASyncDBConnectionThread::doNewCommand()
// todo: need to report the error // todo: need to report the error
} }
} }
}
} }
@ -489,6 +487,9 @@ void ASyncDBConnection::closeConnection()
bool ASyncDBConnection::send(const std::string &command, on_result_callback on_result) bool ASyncDBConnection::send(const std::string &command, on_result_callback on_result)
{ {
if (command.empty())
return false;
{ {
std::lock_guard<std::mutex> lg(m_threadData->m_commandQueue.m_mutex); std::lock_guard<std::mutex> lg(m_threadData->m_commandQueue.m_mutex);
m_threadData->m_commandQueue.m_queue.emplace(command, on_result); m_threadData->m_commandQueue.m_queue.emplace(command, on_result);