Skip to content

Commit

Permalink
fix(core): DB transaction issue (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
garnier-quentin committed Dec 4, 2020
1 parent 3618e63 commit c24c9f9
Showing 1 changed file with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ sub new {

sub database_init_transaction {
my ($self, %options) = @_;

eval {
$self->{class_object_centreon}->{db_centreon}->transaction_mode(1);
};
if ($@) {

my $status = $self->{class_object_centreon}->{db_centreon}->transaction_mode(1);
if ($status == -1) {
$self->{logger}->writeLogError("$@");
return -1;
}
Expand All @@ -75,14 +73,13 @@ sub database_init_transaction {
sub database_commit_transaction {
my ($self, %options) = @_;

eval {
$self->{class_object_centreon}->commit();
$self->{class_object_centreon}->transaction_mode(0);
};
if ($@) {
my $status = $self->{class_object_centreon}->commit();
if ($status == -1) {
$self->{logger}->writeLogError("$@");
return -1;
}

$self->{class_object_centreon}->transaction_mode(0);
return 0;
}

Expand Down

0 comments on commit c24c9f9

Please sign in to comment.