Prune only when history size is exceeded

The documentation stated that at most `max_sescmd_history` commands were
kept but in reality the number of commands kept in the history was one
command smaller than what was documented.
This commit is contained in:
Markus Mäkelä 2019-02-11 10:51:05 +02:00
parent b93d35ab03
commit aea64aede2
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19

View File

@ -517,7 +517,8 @@ bool RWSplitSession::route_session_write(GWBUF* querybuf, uint8_t command, uint3
}
}
if (m_config.max_sescmd_history > 0 && m_sescmd_list.size() >= m_config.max_sescmd_history)
if (m_config.max_sescmd_history > 0 && m_sescmd_list.size() >= m_config.max_sescmd_history
&& !m_config.prune_sescmd_history)
{
static bool warn_history_exceeded = true;
if (warn_history_exceeded)
@ -540,7 +541,7 @@ bool RWSplitSession::route_session_write(GWBUF* querybuf, uint8_t command, uint3
}
if (m_config.prune_sescmd_history && !m_sescmd_list.empty()
&& m_sescmd_list.size() + 1 >= m_config.max_sescmd_history)
&& m_sescmd_list.size() >= m_config.max_sescmd_history)
{
// Close to the history limit, remove the oldest command
prune_to_position(m_sescmd_list.front()->get_position());