Commit cca74db3 authored by IKEDA Soji's avatar IKEDA Soji
Browse files

Small fix: Aborted connection may crash the process.

parent 2cdbd451
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
# Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, # Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
# 2006, 2007, 2008, 2009, 2010, 2011 Comite Reseau des Universites # 2006, 2007, 2008, 2009, 2010, 2011 Comite Reseau des Universites
# Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017 GIP RENATER # Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017 GIP RENATER
# Copyright 2017, 2018, 2019 The Sympa Community. See the AUTHORS.md file at # Copyright 2017, 2018, 2019, 2021 The Sympa Community. See the
# the top-level directory of this distribution and at # AUTHORS.md file at the top-level directory of this distribution and at
# <https://github.com/sympa-community/sympa.git>. # <https://github.com/sympa-community/sympa.git>.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
...@@ -108,6 +108,13 @@ sub connect { ...@@ -108,6 +108,13 @@ sub connect {
$self); $self);
return 1; return 1;
} }
# Disconnected: Transaction (if any) was aborted.
if (delete $self->{_sdbTransactionLevel}) {
$log->syslog('err', 'Transaction on database %s was aborted: %s',
$self, $DBI::errstr);
$self->set_persistent($self->{_sdbPrevPersistency});
return undef;
}
# Do we have required parameters? # Do we have required parameters?
foreach my $param (@{$self->required_parameters}) { foreach my $param (@{$self->required_parameters}) {
...@@ -425,6 +432,9 @@ sub begin { ...@@ -425,6 +432,9 @@ sub begin {
sub _finalize_transaction { sub _finalize_transaction {
my $self = shift; my $self = shift;
unless (defined $self->{_sdbTransactionLevel}) {
return;
}
unless ($self->{_sdbTransactionLevel}) { unless ($self->{_sdbTransactionLevel}) {
die 'bug in logic. Ask developer'; die 'bug in logic. Ask developer';
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment