You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by pa...@apache.org on 2007/11/24 08:44:51 UTC
svn commit: r597822 - /spamassassin/trunk/lib/Mail/SpamAssassin/Client.pm
Author: parker
Date: Fri Nov 23 23:44:50 2007
New Revision: 597822
URL: http://svn.apache.org/viewvc?rev=597822&view=rev
Log:
Bug 5572: Add timeout to client code.
Modified:
spamassassin/trunk/lib/Mail/SpamAssassin/Client.pm
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Client.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Client.pm?rev=597822&r1=597821&r2=597822&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Client.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Client.pm Fri Nov 23 23:44:50 2007
@@ -24,9 +24,18 @@
=head1 SYNOPSIS
- my $client = new Mail::SpamAssassin::Client({port => 783,
- host => 'localhost',
- username => 'someuser'});
+ my $client = new Mail::SpamAssassin::Client({
+ port => 783,
+ host => 'localhost',
+ username => 'someuser'});
+ or
+
+ my $client = new Mail::SpamAssassin::Client({
+ socketpath => '/path/to/socket',
+ username => 'someuser'});
+
+ Optionally takes timeout, which is applied to IO::Socket for the
+ initial connection. If not supplied, it defaults to 30 seconds.
if ($client->ping()) {
print "Ping is ok\n";
@@ -84,6 +93,10 @@
$self->{username} = $args->{username};
}
+ if ($args->{timeout}) {
+ $self->{timeout} = $args->{timeout} || 30;
+ }
+
bless($self, $class);
$self;
@@ -252,8 +265,8 @@
return undef unless ($resp_code == 0);
- my $did_set;
- my $did_remove;
+ my $did_set = '';
+ my $did_remove = '';
while ($line = <$remote>) {
if ($line =~ /DidSet: (.*)/i) {
@@ -443,12 +456,14 @@
if ($self->{socketpath}) {
$remote = IO::Socket::UNIX->new( Peer => $self->{socketpath},
Type => SOCK_STREAM,
+ Timeout => $self->{timeout},
);
}
else {
$remote = IO::Socket::INET->new( Proto => "tcp",
PeerAddr => $self->{host},
PeerPort => $self->{port},
+ Timeout => $self->{timeout},
);
}