improve error handling

git-svn-id: https://svn.perl.org/qpsmtpd/branches/v010@50 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
Ask Bjørn Hansen 2002-09-08 10:02:10 +00:00
parent 931c3dbdfa
commit 859a3589aa

View File

@ -31,12 +31,16 @@ sub check_spam {
my $port = 783; my $port = 783;
if ($port =~ /\D/) { $port = getservbyname($port, 'tcp') } if ($port =~ /\D/) { $port = getservbyname($port, 'tcp') }
die "No port" unless $port; die "No port" unless $port;
my $iaddr = inet_aton($remote) || die "no host: $remote"; my $iaddr = inet_aton($remote) or
$self->log(1, "Could not resolve host: $remote") and return (DECLINED);
my $paddr = sockaddr_in($port, $iaddr); my $paddr = sockaddr_in($port, $iaddr);
my $proto = getprotobyname('tcp'); my $proto = getprotobyname('tcp');
socket(SPAMD, PF_INET, SOCK_STREAM, $proto) || die "socket: $!"; socket(SPAMD, PF_INET, SOCK_STREAM, $proto)
connect(SPAMD, $paddr) || warn "SA: connect: $!", return undef; or $self->log(1, "Could not open socket: $!") and return (DECLINED);
connect(SPAMD, $paddr)
or $self->log(1, "Could not connect to spamassassin daemon: $!") and return DECLINED;
SPAMD->autoflush(1); SPAMD->autoflush(1);