/usr/share/perl5/AnyEvent/Memcached/Conn.pm is in libanyevent-memcached-perl 0.06-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | package #hide
AnyEvent::Memcached::Conn;
use common::sense 2;m{
use strict;
use warnings;
}x;
use base 'AnyEvent::Connection::Raw';
use AnyEvent::Memcached;
use AnyEvent::Connection::Util;
our $NL = "\015\012";
our $QRNL = qr<\015?\012>;
our $VERSION = $AnyEvent::Memcached::VERSION;
sub reader {
my ($self,%args) = @_;
$args{cb} or return $self->event( error => "no cb for command at @{[ (caller)[1,2] ]}" );
$self->{h} or return $args{cb}->(undef,"Not connected");
my $result = $args{res} || {};
my $ar = ref $result eq 'ARRAY' ? 1 : 0;
my $cut = exists $args{namespace} ? length $args{namespace} : 0;
my $reader;$reader = sub {
shift;
defined( local $_ = shift ) or return $args{cb}(undef,@_);
warn "<<$args{id} $_" if $self->{debug};
if ($_ eq "END") {
undef $reader;
$args{cb}( $result );
}
elsif (substr($_,0,5) eq 'ERROR') {
undef $reader;
$args{cb}( undef, $_ );
}
elsif (!length) {
warn "Skip empty line";
$self->{h}->unshift_read( line => $reader);
}
elsif( /^VALUE (\S+) (\d+) (\d+)(?:| (.+))$/ ) {
my ($key,$flags,$len,$cas) = ($1,$2,$3,$4);
#warn "have to read $1 $2 $3 $4";
$self->recv( $3+2 => cb => sub {
#shift;
my $data = shift;
substr($data,$len) = ''; # trim out data outside length
#$data = substr($data,0,length($data)-2);
$key = substr($key, $cut) if substr($key, 0, $cut) eq $args{namespace};
warn "+ received data $key: $data" if $self->{debug};
my $v = {
data => $data,
flags => $flags,
defined $cas ? (cas => $cas) : (),
};
if ($ar) {
push @$result, $key, $v;
} else {
$result->{$key} = $v;#{ data => $data, $cas ? (cas => $cas) : () };
}
$self->{h}->unshift_read( line => $reader);
});
}
else {
die "Wrong data received: ".dumper($_)."($!)";
#$args{cb}(undef,$_);
#$self->handle_errors($_);
}
};
$self->{h}->push_read( line => $reader );
}
1;
1;
|