minor spacing changes, remove unused Server lookup

This commit is contained in:
Isaac Connor 2018-06-11 14:07:49 -04:00
parent 578efb3a76
commit d1f658bf30
1 changed files with 9 additions and 14 deletions

View File

@ -172,7 +172,7 @@ if ( !$server_up ) {
exit();
} elsif ( $command ne 'startup' ) {
print("Unable to connect to server using socket at " . SOCK_FILE . "\n");
exit( -1 );
exit(-1);
}
# The server isn't there
@ -210,7 +210,7 @@ if ( ($command eq 'check') && !$daemon ) {
# The server is there, connect to it
CLIENT->autoflush();
my $message = join(';', $command, ( $daemon ? $daemon : () ), @args );
my $message = join(';', $command, ( $daemon ? $daemon : () ), @args);
print(CLIENT $message);
shutdown(CLIENT, 1);
while( my $line = <CLIENT> ) {
@ -292,22 +292,15 @@ sub run {
my $win = $rin;
my $ein = $win;
my $timeout = 1;
my $Server = undef;
my $secs_count = 0;
if ( $Config{ZM_SERVER_ID} ) {
require ZoneMinder::Server;
$Server = new ZoneMinder::Server($Config{ZM_SERVER_ID});
dPrint(ZoneMinder::Logger::INFO, 'Loading Server record have ' . $$Server{Name});
}
while( !$zm_terminate ) {
if ( $Config{ZM_SERVER_ID} ) {
if ( ! ( $secs_count % 60 ) ) {
Debug("Connecting");
while ( (!$zm_terminate) and !($dbh and $dbh->ping()) ) {
Warning("Not connected to db ($dbh)".($dbh?" ping(".$dbh->ping().")":''). ($DBI::errstr?" errstr($DBI::errstr)":'').' Reconnecting');
Warning("Not connected to db ($dbh)".($dbh?' ping('.$dbh->ping().')':''). ($DBI::errstr?" errstr($DBI::errstr)":'').' Reconnecting');
$dbh = zmDbConnect();
}
my @cpuload = CpuLoad();
@ -341,7 +334,7 @@ sub run {
# Do nothing, this is all we're here for
dPrint(ZoneMinder::Logger::WARNING, "Already running, ignoring command '$command'\n");
} elsif ( $command eq 'shutdown' ) {
# Breka out of while loop
# Break out of while loop
last;
} elsif ( $command eq 'check' ) {
check($daemon, @args);
@ -454,7 +447,9 @@ sub start {
$cmd_hash{$process->{command}} = $pid_hash{$cpid} = $process;
sigprocmask(SIG_SETMASK, $sigset) or Fatal("Can't restore SIGCHLD: $!");
} elsif ( defined($cpid) ) {
# Force reconnection to the db.
# Child process
# Force reconnection to the db. $dbh got copied, but isn't really valid anymore.
$dbh = zmDbConnect(1);
logReinit();
@ -471,7 +466,7 @@ sub start {
my @good_args;
foreach my $arg ( @args ) {
# Detaint arguments, if they look ok
# Detaint arguments, if they look ok
if ( $arg =~ /^(-{0,2}[\w\/?&=.-]+)$/ ) {
push @good_args, $1;
} else {
@ -487,8 +482,8 @@ sub start {
POSIX::close($fd++);
}
# Child process
$SIG{CHLD} = 'DEFAULT';
$SIG{HUP} = 'DEFAULT';
$SIG{INT} = 'DEFAULT';
$SIG{TERM} = 'DEFAULT';
$SIG{ABRT} = 'DEFAULT';