… | |
… | |
561 | |
561 | |
562 | our %node_req = ( |
562 | our %node_req = ( |
563 | # internal services |
563 | # internal services |
564 | |
564 | |
565 | # monitoring |
565 | # monitoring |
566 | mon0 => sub { # stop monitoring a port |
566 | mon0 => sub { # stop monitoring a port for another node |
567 | my $portid = shift; |
567 | my $portid = shift; |
568 | my $node = $SRCNODE; |
568 | my $node = $SRCNODE; |
569 | $NODE{""}->unmonitor ($portid, delete $node->{rmon}{$portid}); |
569 | $NODE{""}->unmonitor ($portid, delete $node->{rmon}{$portid}); |
570 | }, |
570 | }, |
571 | mon1 => sub { # start monitoring a port |
571 | mon1 => sub { # start monitoring a port for another node |
572 | my $portid = shift; |
572 | my $portid = shift; |
573 | my $node = $SRCNODE; |
573 | my $node = $SRCNODE; |
574 | Scalar::Util::weaken $node; |
574 | Scalar::Util::weaken $node; |
575 | $NODE{""}->monitor ($portid, $node->{rmon}{$portid} = sub { |
575 | $NODE{""}->monitor ($portid, $node->{rmon}{$portid} = sub { |
576 | delete $node->{rmon}{$portid}; |
576 | delete $node->{rmon}{$portid}; |
577 | $node->send (["", kil => $portid, @_]) |
577 | $node->send (["", kil0 => $portid, @_]) |
578 | if $node && $node->{transport}; |
578 | if $node && $node->{transport}; |
579 | }); |
579 | }); |
580 | }, |
580 | }, |
|
|
581 | # another node has killed a monitored port |
581 | kil => sub { |
582 | kil0 => sub { |
582 | my $cbs = delete $SRCNODE->{lmon}{+shift} |
583 | my $cbs = delete $SRCNODE->{lmon}{+shift} |
583 | or return; |
584 | or return; |
584 | |
585 | |
585 | $_->(@_) for @$cbs; |
586 | $_->(@_) for @$cbs; |
586 | }, |
587 | }, |
587 | |
588 | |
588 | # "public" services - not actually public |
589 | # "public" services - not actually public |
|
|
590 | |
|
|
591 | # another node wants to kill a local port |
|
|
592 | kil => sub { |
|
|
593 | $NODE{""}->kill (@_); |
|
|
594 | }, |
589 | |
595 | |
590 | # relay message to another node / generic echo |
596 | # relay message to another node / generic echo |
591 | snd => \&snd, |
597 | snd => \&snd, |
592 | snd_multiple => sub { |
598 | snd_multiple => sub { |
593 | snd @$_ for @_ |
599 | snd @$_ for @_ |