Patches for Perl binding
Chris Ochs
chris@paymentonline.com
Fri, 19 Mar 2004 11:57:00 -0800
Is this what could be causing the non blocking IO to fail for me with perl
5.6? I had to comment out the IO::Handle::blocking calls on freebsd
5.2/perl5.6 or the connect would return undefined in _connect_sock. I would
really like to be able to use non blocking io again...
Chris
----- Original Message -----
From: "Dave Evans" <memcached-list-20040309@djce.org.uk>
To: <memcached@lists.danga.com>
Sent: Friday, March 19, 2004 10:57 AM
Subject: Patches for Perl binding
> Hello,
>
> Please find attached for your consideration two patches for the Perl
> binding (Cache::Memcached).
>
> "perl56compat.patch" provides Perl 5.6 compatibility, simply by using
> $!==EWOULDBLOCK (etc) instead of the Perl-5.8-specific construct
> $!{EWOULDBLOCK}. I haven't tested it on Perls earlier than 5.6, but it
> made the difference for 5.6.1.
>
> "undef.patch" initialises two variables before calling select(), thus
> fixing the "use of uninitialised value" errors which previously often
> occurred (assuming warnings were enabled).
>
> Bye,
>
> --
> Dave
>
> PGP key: http://rudolf.org.uk/pgpkey
>
----------------------------------------------------------------------------
----
> --- Memcached.pm Fri Mar 19 14:21:42 2004
> +++ Memcached.pm Fri Mar 19 14:21:21 2004
> @@ -12,6 +12,7 @@
> use Storable ();
> use Socket qw(MSG_NOSIGNAL PF_INET SOCK_STREAM);
> use IO::Handle ();
> +use Errno qw( EINPROGRESS EWOULDBLOCK EISCONN );
>
> BEGIN {
> eval "use Time::HiRes qw (alarm);";
> @@ -131,7 +132,7 @@
>
> my $ret = connect($sock, $sin);
>
> - if (!$ret && $timeout && $!{'EINPROGRESS'}) {
> + if (!$ret && $timeout && $!==EINPROGRESS) {
>
> my $win='';
> vec($win, fileno($sock), 1) = 1;
> @@ -139,7 +140,7 @@
> if (select(undef, $win, undef, $timeout) > 0) {
> $ret = connect($sock, $sin);
> # EISCONN means connected & won't re-connect, so success
> - $ret = 1 if !$ret && $!{'EISCONN'};
> + $ret = 1 if !$ret && $!==EISCONN;
> }
> }
>
> @@ -449,7 +450,7 @@
> $state{$sock} - $offset{$sock},
> $offset{$sock});
> return
> - if !defined($res) and $!{EWOULDBLOCK};
> + if !defined($res) and $!==EWOULDBLOCK;
> if ($res == 0) { # catches 0=conn closed or undef=error
> $dead->($sock);
> return;
> @@ -468,7 +469,7 @@
> $res = sysread($sock, $buf{$sock},
> 2048, $offset{$sock});
> return
> - if !defined($res) and $!{EWOULDBLOCK};
> + if !defined($res) and $!==EWOULDBLOCK;
> if ($res == 0) {
> $dead->($sock);
> return;
> @@ -526,7 +527,7 @@
>
> $res = send($sock, $buf{$sock}, $FLAG_NOSIGNAL);
> return
> - if not defined $res and $!{EWOULDBLOCK};
> + if not defined $res and $!==EWOULDBLOCK;
> unless ($res > 0) {
> $dead->($sock);
> return;
>
----------------------------------------------------------------------------
----
> --- Memcached.pm Tue Feb 3 18:27:43 2004
> +++ Memcached.pm Fri Mar 19 14:21:42 2004
> @@ -552,7 +552,7 @@
> while(1) {
> if ($active_changed) {
> last unless %reading or %writing; # no sockets left?
> - ($rin, $win) = (undef, undef);
> + ($rin, $win) = ('', '');
> foreach (keys %reading) {
> vec($rin, fileno($_), 1) = 1;
> }
>