The Task::Add() function appends to the back of the tasks vector without any upper limit. It would be better to enforce an upper limit and also check for any open slots in the current allocated slots.
|
int32_t Task::Add(string command, string node, float timeout) |
|
{ |
|
mtx.lock(); |
|
tasks.resize(tasks.size()+1); |
|
tasks.back().startmjd = currentmjd(); |
|
tasks.back().state = 0; |
|
tasks.back().command = command; |
|
tasks.back().timeout = timeout; |
|
const int32_t task_identifier = decisec(tasks.back().startmjd); |
|
if (node.empty()) |
|
{ |
|
tasks.back().path = data_base_path(NodeName, "temp", AgentName, data_name(tasks.back().startmjd, "task", NodeName, AgentName)); |
|
} |
|
else |
|
{ |
|
tasks.back().path = data_base_path(node, "temp", AgentName, data_name(tasks.back().startmjd, "task", NodeName, AgentName)); |
|
} |
|
mtx.unlock(); |
|
return task_identifier; |
|
} |
The
Task::Add()function appends to the back of thetasksvector without any upper limit. It would be better to enforce an upper limit and also check for any open slots in the current allocated slots.cosmos-core/libraries/agent/task.cpp
Lines 77 to 96 in 7b901da