From: Matt S Trout Date: Mon, 11 Jun 2012 22:59:17 +0000 (+0100) Subject: minor cleanups, better error reporting X-Git-Tag: v0.001001~22 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1d26d6f9aa2d284f6454989a7943d5bc04c6cdfb;p=scpubgit%2FObject-Remote.git minor cleanups, better error reporting --- diff --git a/lib/Object/Remote/Connection.pm b/lib/Object/Remote/Connection.pm index e3cb452..2dcaa36 100644 --- a/lib/Object/Remote/Connection.pm +++ b/lib/Object/Remote/Connection.pm @@ -83,6 +83,7 @@ BEGIN { eval { require Object::Remote::Connector::Local }; eval { require Object::Remote::Connector::LocalSudo }; eval { require Object::Remote::Connector::SSH }; + eval { require Object::Remote::Connector::UNIX }; } sub new_from_spec { @@ -211,7 +212,9 @@ sub _receive_data_from { my ($self, $fh) = @_; my $rb = $self->_receive_data_buffer; my $ready = $self->ready_future->is_ready; - if (sysread($fh, $$rb, 1024, length($$rb)) > 0) { + my $len = sysread($fh, $$rb, 1024, length($$rb)); + my $err = defined($len) ? undef : ": $!"; + if (defined($len) and $len > 0) { while ($$rb =~ s/^(.*)\n//) { if ($ready) { $self->_receive($1); @@ -229,7 +232,7 @@ sub _receive_data_from { on_read_ready => 1 ); my $outstanding = $self->outstanding_futures; - $_->fail("Connection lost") for values %$outstanding; + $_->fail("Connection lost${err}") for values %$outstanding; %$outstanding = (); $self->on_close->done(); } diff --git a/lib/Object/Remote/Handle.pm b/lib/Object/Remote/Handle.pm index 1a757ab..cc0d4ff 100644 --- a/lib/Object/Remote/Handle.pm +++ b/lib/Object/Remote/Handle.pm @@ -27,7 +27,9 @@ sub proxy { sub BUILD { my ($self, $args) = @_; - unless ($self->id) { + if ($self->id) { + $self->disarm_free; + } else { die "No id supplied and no class either" unless $args->{class}; ref($_) eq 'HASH' and $_ = [ %$_ ] for $args->{args}; $self->_set_id(