From 76e9c1e434a2d85791947b4c28d09e2c56330217 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 16 Nov 2009 19:39:34 +0300 Subject: * Some more clarifications to perl api --- perl/lib/Mail/Rspamd/Client.pm | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'perl') diff --git a/perl/lib/Mail/Rspamd/Client.pm b/perl/lib/Mail/Rspamd/Client.pm index bb405a7b4..6026cc448 100644 --- a/perl/lib/Mail/Rspamd/Client.pm +++ b/perl/lib/Mail/Rspamd/Client.pm @@ -30,7 +30,6 @@ the spamd protocol. package Mail::Rspamd::Client; use IO::Socket; -use IO::Select; use vars qw($VERSION); $VERSION = "1.00"; @@ -154,8 +153,14 @@ sub check { return undef unless $self->_get_io_readiness($remote, 0); - my $in; - return undef unless sysread($remote, $in, 512); + my $in, $res, $offset = 0; + do { + $res = sysread($remote, $in, 512, $offset); + if ($res > 0 && $res < 512) { + $self->_get_io_readiness($remote, 0); + } + $offset += $res; + } while ($res > 0); my ($version, $resp_code, $resp_msg) = $self->_parse_response_line($in); @@ -415,18 +420,17 @@ sub _mark_dead { sub _get_io_readiness { my ($self, $sock, $is_write) = @_; - my $s = IO::Select->new(); - $s->add($sock); + my $w = ''; + vec($w, fileno($sock), 1) = 1; if ($is_write) { - @ready = $s->can_write($self->{timeout}); + return select(undef, $w, undef, $self->{timeout}); } else { - @ready = $s->can_read($self->{timeout}); + return select($w, undef,undef, $self->{timeout}); } - - scalar(@ready); + undef; } =head2 _parse_response_line -- cgit v1.2.3