Merge branch 'ent-5908-agentes-duplicados' into 'develop'
Lock on LIFO mode if the agent does not exist to prevent duplicates. See merge request artica/pandorafms!3372
This commit is contained in:
commit
539e647a68
|
@ -117,7 +117,7 @@ sub run ($) {
|
|||
###############################################################################
|
||||
sub data_producer ($) {
|
||||
my $self = shift;
|
||||
my $pa_config = $self->getConfig ();
|
||||
my ($pa_config, $dbh) = ($self->getConfig (), $self->getDBH ());
|
||||
|
||||
my @tasks;
|
||||
my @files;
|
||||
|
@ -162,7 +162,7 @@ sub data_producer ($) {
|
|||
next if ($file !~ /^(.*)[\._]\d+\.data$/);
|
||||
my $agent_name = $1;
|
||||
|
||||
next if (agent_lock($pa_config, $agent_name) == 0);
|
||||
next if (agent_lock($pa_config, $dbh, $agent_name) == 0);
|
||||
|
||||
push (@tasks, $file);
|
||||
}
|
||||
|
@ -1064,9 +1064,16 @@ sub process_xml_matrix_network {
|
|||
# Get a lock on the given agent. Return 1 on success, 0 otherwise.
|
||||
##########################################################################
|
||||
sub agent_lock {
|
||||
my ($pa_config, $agent_name) = @_;
|
||||
my ($pa_config, $dbh, $agent_name) = @_;
|
||||
|
||||
return 1 if ($pa_config->{'dataserver_lifo'} == 1);
|
||||
# Do not lock on LIFO mode if the agent already exist.
|
||||
# get_agent_id will be called again from process_xml_data,
|
||||
# so the should be no race conditions if the agent does
|
||||
# not exist.
|
||||
if ($pa_config->{'dataserver_lifo'} == 1 &&
|
||||
get_agent_id ($dbh, $agent_name) > 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
$AgentSem->down ();
|
||||
if (defined ($Agents{$agent_name})) {
|
||||
|
|
Loading…
Reference in New Issue