Log the reason for croaking before croaking.

This commit is contained in:
Isaac Connor 2016-02-19 10:57:52 -05:00
parent 46efe9c1e0
commit 3a512f87a5
1 changed files with 14 additions and 6 deletions

View File

@ -63,9 +63,18 @@ sub open
local *sfh;
unlink( $self->{path} );
my $saddr = sockaddr_un( $self->{path} );
socket( *sfh, PF_UNIX, SOCK_STREAM, 0 ) or croak( "Can't open socket: $!" );
bind( *sfh, $saddr ) or croak( "Can't bind: $!" );
listen( *sfh, SOMAXCONN ) or croak( "Can't listen: $!" );
if ( ! socket( *sfh, PF_UNIX, SOCK_STREAM, 0 ) ) {
Error( "Can't open unix socket at $$self{path}: $!" );
croak( "Can't open unix socket at $$self{path}: $!" );
}
if ( ! bind( *sfh, $saddr ) ) {
Error( "Can't bind unix socket at $$self{path}: $!" );
croak( "Can't bind unix socket at $$self{path}: $!" );
}
if ( ! listen( *sfh, SOMAXCONN ) ) {
Error( "Can't listen: $!" );
croak( "Can't listen: $!" );
}
$self->{handle} = *sfh;
}
@ -93,12 +102,11 @@ __END__
=head1 NAME
ZoneMinder::Database - Perl extension for blah blah blah
ZoneMinder::Trigger::Channel::Unix - Object for Unix socket channel
=head1 SYNOPSIS
use ZoneMinder::Database;
blah blah blah
See zmtrigger.pl
=head1 DESCRIPTION