MXS-2474 Ignore attempts to re-register a housekeeper task
It is an error to register the same task multiple times, but for a maintenance release it is simpler and less risky to simply ignore an attempt (that BLR does) to do that. Allowing a task to be registered anew causes behaviour akin to a leak.
This commit is contained in:
@ -12,6 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
#include <maxscale/ccdefs.hh>
|
#include <maxscale/ccdefs.hh>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -205,8 +206,30 @@ void Housekeeper::stop()
|
|||||||
void Housekeeper::add(const Task& task)
|
void Housekeeper::add(const Task& task)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(m_lock);
|
std::lock_guard<std::mutex> guard(m_lock);
|
||||||
|
|
||||||
|
auto i = std::find_if(m_tasks.begin(), m_tasks.end(), Task::NameMatch(task.name));
|
||||||
|
if (i == m_tasks.end())
|
||||||
|
{
|
||||||
m_tasks.push_back(task);
|
m_tasks.push_back(task);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const Task& existing = *i;
|
||||||
|
|
||||||
|
bool identical = false;
|
||||||
|
if (task.func == existing.func
|
||||||
|
&& task.data == existing.data
|
||||||
|
&& task.frequency == existing.frequency)
|
||||||
|
{
|
||||||
|
identical = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
MXS_INFO("Housekeeper task `%s` added anew, all settings %s identical. "
|
||||||
|
"Second attempt to add is ignored.",
|
||||||
|
identical ? "ARE" : "are NOT",
|
||||||
|
task.name.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Housekeeper::remove(std::string name)
|
void Housekeeper::remove(std::string name)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user