From: Tyler Riddle Date: Thu, 29 Nov 2012 23:48:45 +0000 (-0800) Subject: fix left over remote object hang bug X-Git-Tag: v0.003001_01~58 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2FObject-Remote.git;a=commitdiff_plain;h=d2eadebbdb4416f421ffd5298c782fdc32f388e7;hp=302ecfbf4056a977f44f185cbfa925e3886d0c1a fix left over remote object hang bug --- diff --git a/lib/Object/Remote/Connection.pm b/lib/Object/Remote/Connection.pm index 3832bfa..e47b8fc 100644 --- a/lib/Object/Remote/Connection.pm +++ b/lib/Object/Remote/Connection.pm @@ -101,11 +101,27 @@ after BUILD => sub { sub BUILD { } +sub is_valid { + my ($self) = @_; + my $closed = $self->on_close->is_ready; + + log_trace { "Connection closed: $closed" }; + return ! $closed; +} + sub _fail_outstanding { my ($self, $error) = @_; - Dlog_debug { "$$ Failing outstanding futures with '$error' for connection $_" } $self->_id; my $outstanding = $self->outstanding_futures; - $_->fail("$error\n") for values %$outstanding; + + Dlog_debug { + sprintf "Failing %i outstanding futures with '$error'", scalar(keys(%$outstanding)) + }; + + foreach(keys(%$outstanding)) { + log_trace { "Failing future for $_" }; + my $future = $outstanding->{$_}; + } + %$outstanding = (); return; } @@ -325,6 +341,11 @@ sub send_discard { sub _send { my ($self, $to_send) = @_; my $fh = $self->send_to_fh; + + unless ($self->is_valid) { + die "Attempt to invoke _send on a connection that is not valid"; + } + Dlog_trace { "Starting to serialize data in argument to _send for connection $_" } $self->_id; my $serialized = $self->_serialize($to_send)."\n"; Dlog_trace { my $l = length($serialized); "serialization is completed; sending '$l' characters of serialized data to $_" } $fh; diff --git a/lib/Object/Remote/Handle.pm b/lib/Object/Remote/Handle.pm index 3a3bcc1..8b1bd31 100644 --- a/lib/Object/Remote/Handle.pm +++ b/lib/Object/Remote/Handle.pm @@ -59,6 +59,7 @@ sub call { my ($self, $method, @args) = @_; my $w = wantarray; log_trace { my $def = defined $w ? 1 : 0; "call() has been invoked on a remote handle; wantarray: '$def'" }; + $method = "start::${method}" if (caller(0)||'') eq 'start'; future { $self->connection->send(call => $self->id, $w, $method, @args)