INET connector
[scpubgit/Object-Remote.git] / lib / Object / Remote / Handle.pm
index 7e9c218..782ddf6 100644 (file)
@@ -4,10 +4,6 @@ use Object::Remote::Proxy;
 use Scalar::Util qw(weaken blessed);
 use Object::Remote::Logging qw ( :log :dlog router );
 use Object::Remote::Future;
-#must find way to exclude certain log events
-#from being forwarded - log events generated in
-#response to log events cause exploding
-#use Object::Remote::Logging qw(:log);
 use Module::Runtime qw(use_module);
 use Moo;
 
@@ -59,12 +55,12 @@ sub call {
   my ($self, $method, @args) = @_;
   my $w = wantarray;
   my $id = $self->id;
-  
+
   $method = "start::${method}" if (caller(0)||'') eq 'start';
   log_trace { "call('$method') has been invoked on remote handle '$id'; creating future" };
 
   future {
-    log_debug { "Invoking send on connection for handle '$id' method $method" };
+    log_debug { "Invoking send on connection for handle '$id' method '$method'" };
     $self->connection->send(call => $id, $w, $method, @args)
   };
 }
@@ -86,7 +82,11 @@ sub DEMOLISH {
   my ($self, $gd) = @_;
   Dlog_trace { "Demolishing remote handle $_" } $self->id;
   return if $gd or $self->disarmed_free;
-  $self->connection->send_free($self->id);
+  #this could happen after the connection has gone away
+  eval { $self->connection->send_free($self->id) };
+  if ($@ && $@ !~ m/^Attempt to invoke _send on a connection that is not valid/) {
+    die "Could not invoke send_free on connection for handle " . $self->id;
+  }
 }
 
 1;