Improve handling of query queue.

This commit is contained in:
Bartosz Taudul 2020-04-01 21:05:25 +02:00
parent b6ce693ede
commit 9e8089ec1a

View File

@ -2821,12 +2821,19 @@ void Worker::Exec()
#endif #endif
} }
while( !m_serverQueryQueue.empty() && m_serverQuerySpaceLeft > 0 ) if( !m_serverQueryQueue.empty() && m_serverQuerySpaceLeft > 0 )
{ {
m_serverQuerySpaceLeft--; const auto toSend = std::min( m_serverQuerySpaceLeft, m_serverQueryQueue.size() );
const auto& query = m_serverQueryQueue.back(); m_sock.Send( m_serverQueryQueue.data(), toSend * ServerQueryPacketSize );
m_sock.Send( &query, ServerQueryPacketSize ); m_serverQuerySpaceLeft -= toSend;
m_serverQueryQueue.pop_back(); if( toSend == m_serverQueryQueue.size() )
{
m_serverQueryQueue.clear();
}
else
{
m_serverQueryQueue.erase( m_serverQueryQueue.begin(), m_serverQueryQueue.begin() + toSend );
}
} }
} }
@ -3011,7 +3018,7 @@ void Worker::Query( ServerQuery type, uint64_t data, uint32_t extra )
} }
else else
{ {
m_serverQueryQueue.insert( m_serverQueryQueue.begin(), query ); m_serverQueryQueue.push_back( query );
} }
} }