This replaces Module::Load with Module::Load::Conditional which can actually handle errors.

Then I move the module load call up before the fork so that any errors will be visible and will make zmcontrol.pl die quickly instead of waiting 11 seconds for something that will never happen.
This commit is contained in:
Isaac Connor 2014-12-12 16:33:18 -05:00
parent 9d9396c8bc
commit 78f0243c69
1 changed files with 5 additions and 3 deletions

View File

@ -33,7 +33,7 @@ use Getopt::Long;
use POSIX qw/strftime EPIPE/;
use Socket;
#use Data::Dumper;
use Module::Load;
use Module::Load::Conditional qw{can_load};;
use constant MAX_CONNECT_DELAY => 10;
use constant MAX_COMMAND_WAIT => 1800;
@ -129,6 +129,10 @@ if ( !$server_up )
Info( "Starting control server $id/$protocol" );
close( CLIENT );
if ( ! can_load( modules => { "ZoneMinder::Control::$protocol" => undef } ) ) {
Fatal("Can't load ZoneMinder::Control::$protocol");
}
if ( my $cpid = fork() )
{
logReinit();
@ -156,8 +160,6 @@ if ( !$server_up )
$0 = $0." --id $id";
load "ZoneMinder::Control::$protocol";
my $control = "ZoneMinder::Control::$protocol"->new( $id );
my $control_key = $control->getKey();
$control->loadMonitor();