… | |
… | |
668 | # master selection |
668 | # master selection |
669 | |
669 | |
670 | # master requests |
670 | # master requests |
671 | our %GLOBAL_REQ; # $id => \@req |
671 | our %GLOBAL_REQ; # $id => \@req |
672 | |
672 | |
673 | sub global_req { |
673 | sub global_req_add { |
674 | my $req = [@_]; |
674 | my $id = shift; |
675 | |
675 | |
676 | $GLOBAL_REQ{$req+0} = $req; |
676 | return if exists $GLOBAL_REQ{$id}; |
|
|
677 | |
|
|
678 | $GLOBAL_REQ{$id} = [@_]; |
677 | |
679 | |
678 | snd $MASTER, @_ |
680 | snd $MASTER, @_ |
679 | if $MASTER; |
681 | if $MASTER; |
|
|
682 | } |
680 | |
683 | |
681 | defined wantarray && AnyEvent::Util::guard { delete $GLOBAL_REQ{$req} } |
684 | sub global_req_del { |
|
|
685 | delete $GLOBAL_REQ{$_[0]}; |
|
|
686 | } |
|
|
687 | |
|
|
688 | sub g_find { |
|
|
689 | global_req_add "g_find $_[0]", g_find => $_[0]; |
682 | } |
690 | } |
683 | |
691 | |
684 | # reply for g_find started in Node.pm |
692 | # reply for g_find started in Node.pm |
685 | $node_req{g_found} = sub { |
693 | $node_req{g_found} = sub { |
|
|
694 | global_req_del "g_find $_[0]"; |
|
|
695 | |
686 | @{ $_[1] } or return; # d'oh |
696 | @{ $_[1] } or return; # d'oh |
687 | |
697 | |
688 | my $node = $NODE{$_[0]} or return; |
698 | my $node = $NODE{$_[0]} or return; |
689 | |
699 | |
690 | local $GLOBAL_DB{"'l"}{$_[0]} = $_[1]; #d# UGLY |
700 | local $GLOBAL_DB{"'l"}{$_[0]} = $_[1]; #d# UGLY |