mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-05-18 19:46:12 -04:00
Merge branch 'storageareas' into zma_to_thread
This commit is contained in:
@@ -53,6 +53,7 @@ use HTTP::Cookies;
|
||||
my $ChannelID = 1; # Usually...
|
||||
my $DefaultFocusSpeed = 50; # Should be between 1 and 100
|
||||
my $DefaultIrisSpeed = 50; # Should be between 1 and 100
|
||||
my ($user,$pass,$host,$port);
|
||||
|
||||
sub open {
|
||||
my $self = shift;
|
||||
@@ -65,7 +66,6 @@ sub open {
|
||||
#
|
||||
# Extract the username/password host/port from ControlAddress
|
||||
#
|
||||
my ($user,$pass,$host,$port);
|
||||
if ( $self->{Monitor}{ControlAddress} =~ /^([^:]+):([^@]+)@(.+)/ ) { # user:pass@host...
|
||||
$user = $1;
|
||||
$pass = $2;
|
||||
@@ -126,6 +126,8 @@ sub PutCmd {
|
||||
Control Device should be set to \"$1\".
|
||||
Control Device currently set to \"$self->{Monitor}{ControlDevice}\".");
|
||||
$self->{Monitor}{ControlDevice} = $1;
|
||||
$self->{UA}->credentials("$host:$port", $self->{Monitor}{ControlDevice}, $user, $pass);
|
||||
return PutCmd($self,$cmd,$content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,9 +108,18 @@ sub zmDbConnect {
|
||||
, $Config{ZM_DB_PASS}
|
||||
);
|
||||
};
|
||||
Error("Error reconnecting to db: errstr:$DBI::errstr error val:$@") if (! $dbh) or $@;
|
||||
$dbh->trace(0) if $dbh;
|
||||
}
|
||||
if ( !$dbh or $@ ) {
|
||||
Error("Error reconnecting to db: errstr:$DBI::errstr error val:$@");
|
||||
} else {
|
||||
$dbh->{AutoCommit} = 1;
|
||||
Fatal('Can\'t set AutoCommit on in database connection')
|
||||
unless $dbh->{AutoCommit};
|
||||
$dbh->{mysql_auto_reconnect} = 1;
|
||||
Fatal('Can\'t set mysql_auto_reconnect on in database connection')
|
||||
unless $dbh->{mysql_auto_reconnect};
|
||||
$dbh->trace( 0 );
|
||||
} # end if success connecting
|
||||
} # end if ! connected
|
||||
return $dbh;
|
||||
} # end sub zmDbConnect
|
||||
|
||||
|
||||
@@ -429,54 +429,10 @@ sub databaseLevel {
|
||||
if ( $this->{databaseLevel} != $databaseLevel ) {
|
||||
if ( $databaseLevel > NOLOG and $this->{databaseLevel} <= NOLOG ) {
|
||||
if ( !$this->{dbh} ) {
|
||||
my $socket;
|
||||
my ( $host, $portOrSocket ) = ( $Config{ZM_DB_HOST} =~ /^([^:]+)(?::(.+))?$/ );
|
||||
|
||||
if ( defined($portOrSocket) ) {
|
||||
if ( $portOrSocket =~ /^\// ) {
|
||||
$socket = ';mysql_socket='.$portOrSocket;
|
||||
} else {
|
||||
$socket = ';host='.$host.';port='.$portOrSocket;
|
||||
}
|
||||
} else {
|
||||
$socket = ';host='.$Config{ZM_DB_HOST};
|
||||
}
|
||||
my $sslOptions = '';
|
||||
if ( $Config{ZM_DB_SSL_CA_CERT} ) {
|
||||
$sslOptions = join(';','',
|
||||
'mysql_ssl=1',
|
||||
'mysql_ssl_ca_file='.$Config{ZM_DB_SSL_CA_CERT},
|
||||
'mysql_ssl_client_key='.$Config{ZM_DB_SSL_CLIENT_KEY},
|
||||
'mysql_ssl_client_cert='.$Config{ZM_DB_SSL_CLIENT_CERT}
|
||||
);
|
||||
}
|
||||
$this->{dbh} = DBI->connect( 'DBI:mysql:database='.$Config{ZM_DB_NAME}
|
||||
.$socket.$sslOptions
|
||||
, $Config{ZM_DB_USER}
|
||||
, $Config{ZM_DB_PASS}
|
||||
);
|
||||
if ( !$this->{dbh} ) {
|
||||
$databaseLevel = NOLOG;
|
||||
Error( 'Unable to write log entries to DB, can\'t connect to database '
|
||||
.$Config{ZM_DB_NAME}
|
||||
.' on host '
|
||||
.$Config{ZM_DB_HOST}
|
||||
);
|
||||
} else {
|
||||
$this->{dbh}->{AutoCommit} = 1;
|
||||
Fatal('Can\'t set AutoCommit on in database connection' )
|
||||
unless( $this->{dbh}->{AutoCommit} );
|
||||
$this->{dbh}->{mysql_auto_reconnect} = 1;
|
||||
Fatal('Can\'t set mysql_auto_reconnect on in database connection' )
|
||||
unless( $this->{dbh}->{mysql_auto_reconnect} );
|
||||
$this->{dbh}->trace( 0 );
|
||||
}
|
||||
$this->{dbh} = ZoneMinder::Database::zmDbConnect();
|
||||
}
|
||||
} elsif ( $databaseLevel <= NOLOG && $this->{databaseLevel} > NOLOG ) {
|
||||
if ( $this->{dbh} ) {
|
||||
$this->{dbh}->disconnect();
|
||||
undef($this->{dbh});
|
||||
}
|
||||
undef($this->{dbh});
|
||||
}
|
||||
$this->{databaseLevel} = $databaseLevel;
|
||||
}
|
||||
@@ -586,7 +542,7 @@ sub logPrint {
|
||||
print(STDERR $message) if $level <= $this->{termLevel};
|
||||
|
||||
if ( $level <= $this->{databaseLevel} ) {
|
||||
if ( ( $this->{dbh} and $this->{dbh}->ping() ) or ( $this->{dbh} = zmDbConnect() ) ) {
|
||||
if ( ( $this->{dbh} and $this->{dbh}->ping() ) or ( $this->{dbh} = ZoneMinder::Database::zmDbConnect() ) ) {
|
||||
|
||||
my $sql = 'INSERT INTO Logs ( TimeKey, Component, Pid, Level, Code, Message, File, Line ) VALUES ( ?, ?, ?, ?, ?, ?, ?, NULL )';
|
||||
$this->{sth} = $this->{dbh}->prepare_cached($sql);
|
||||
|
||||
@@ -453,7 +453,7 @@ sub start {
|
||||
|
||||
$cmd_hash{$process->{command}} = $pid_hash{$cpid} = $process;
|
||||
sigprocmask(SIG_SETMASK, $sigset) or Fatal("Can't restore SIGCHLD: $!");
|
||||
Debug("unblocko child");
|
||||
Debug("unblocking child");
|
||||
} elsif ( defined($cpid) ) {
|
||||
# Force reconnection to the db.
|
||||
$dbh = zmDbConnect(1);
|
||||
|
||||
Reference in New Issue
Block a user