summaryrefslogtreecommitdiff
path: root/Ivy.pm
diff options
context:
space:
mode:
authormertz2002-12-05 13:46:19 +0000
committermertz2002-12-05 13:46:19 +0000
commit25402515c6d38e3ad213fbd53a5b0d0f5316cac9 (patch)
tree104dc56f54b7577e4e156bb9948108f1f248c74a /Ivy.pm
parent5378737fce5816d4fca08990777a88d9536715b1 (diff)
downloadivy-perl-25402515c6d38e3ad213fbd53a5b0d0f5316cac9.zip
ivy-perl-25402515c6d38e3ad213fbd53a5b0d0f5316cac9.tar.gz
ivy-perl-25402515c6d38e3ad213fbd53a5b0d0f5316cac9.tar.bz2
ivy-perl-25402515c6d38e3ad213fbd53a5b0d0f5316cac9.tar.xz
suppressing the print "BroadcastBus: ....." when the agent connects to ivy
when an agent is running on an unknown host, we are now using the ip address in replacement of the hostname in the callback associated to the -statusFunc attribute.
Diffstat (limited to 'Ivy.pm')
-rw-r--r--Ivy.pm20
1 files changed, 11 insertions, 9 deletions
diff --git a/Ivy.pm b/Ivy.pm
index 34914d6..7a2c08d 100644
--- a/Ivy.pm
+++ b/Ivy.pm
@@ -654,7 +654,7 @@ sub start
Reuse => 1);
$self->[supSock]->sockopt (SO_BROADCAST, 1);
foreach my $netBroadcastAddr (@{$self->[broadcastBuses]}) {
- print "BroadcastBus: --", $netBroadcastAddr, "--\n";
+# print "BroadcastBus: --", $netBroadcastAddr, "--\n";
send ($self->[supSock], $bonjourMsg, 0, $netBroadcastAddr) or
carp "Warning in Ivy::start, broadcast of Hello message failed: $!";
}
@@ -1057,7 +1057,7 @@ sub _getBonjour ($)
my $addr = (unpack_sockaddr_in ($inetAddr))[1];
- my $peerName = gethostbyaddr ($addr, AF_INET);
+ my $peerName = gethostbyaddr ($addr, AF_INET) || inet_ntoa($addr);
# on force $peerPort a etre vu comme une valeur numerique
my ($version, $peerPort) = $bonjourMsg =~ /^(\d+)\s+(\d+)/;
@@ -1310,7 +1310,7 @@ _EOL_
push @{$self->[appliList]{$senderName}}, $appSock;
}
- my $host = (gethostbyaddr ($addr, AF_INET))[0] ;
+ my $host = (gethostbyaddr ($addr, AF_INET))[0] || inet_ntoa($addr);
$self->_scanConnStatus ($senderName, "new", "$host");
}
elsif ($type == APP_NAME) {
@@ -1420,11 +1420,9 @@ sub _inetAdrByName ($$) {
keys %{$self->[cnnxion]}))[0];
return ("unknow") unless defined $addrInet;
- print "$addrInet\n";
my ($addr,$port) = $addrInet =~ /(.{4}):(.*)/;
- print "$addr,$port\n";
- my $host = (gethostbyaddr ($addr, AF_INET))[0] ;
+ my $host = (gethostbyaddr ($addr, AF_INET))[0] || inet_ntoa($addr);
return "$host:$port";
} # end _inetAdrByName
@@ -1488,7 +1486,7 @@ sub _removeFileDescriptor ($$)
# regexps par canal
my $addr = substr ($addrInet,0,4);
- my $host = (gethostbyaddr ($addr, AF_INET))[0] ;
+ my $host = (gethostbyaddr ($addr, AF_INET))[0] || inet_ntoa($addr);
$self->_scanConnStatus ($diedAppName, "died", $host) ;
} # end _removeFileDescriptor
@@ -1597,11 +1595,15 @@ sub _scanConnStatus ($$$$)
# par compatibilite avec l'ancienne version, on envoie comme
# deux premiers arguments une ref sur la liste des applis presentes,
- # la liste des applis absentes, mais on rajoute comme troisieme
+ # une ref de la liste des applis absentes, mais on rajoute comme troisieme
# argument une ref sur une table de hash : comme clef les
# applis presentes, comme valeur le nombre d'applis ayant ce nom,
# de facon a detecter plus facilement quand il y a trop d'applis
# de meme nom sur le meme bus.
+ # les nouveaux arguments sont:
+ # le 4eme arg est l'appli nouvelle, deconnecté, qui s'abonne ou se desabonne
+ # le 5eme arg est le statut (actuellement: 'subscribing'|'unsubscribing'|'died'|'new')
+ # le 6eme arg est l'addresse de la machine sur laquelle tourne l'agent
&{$self->[statusFunc]} ([keys %readyApp], \@nonReadyApp, \%readyApp, $appname, $status, $addr);
} # end _scanConnStatus
@@ -1907,7 +1909,7 @@ before running.
=item B<-statusFunc =E<gt> sub {}>
-A callback which is called every time an appli connects on the bus, disconnects from the bus or subscribes to a regexp. When an application is stopping, this function is also called for every disconnecting agent on the bus. The first 3 parameters are a reference to an array of connected appli, a reference to an array of not connected appli (according to the "-neededApp" argument of the new method / function), a reference to a hash table of connected appli (giving the number of such appli). These 3 parameters are maintained for upwards compatibility but should no more be used, since the following three parameters are much easier to use: the name of an appearing / disapearing or subscribing / unsubscribing appli, its status either "new" or "died" or "subscribing" or "unsubscribing", and the hostname where this appli is running / dying OR the subscribed / unsubscribed regexp.
+A callback which is called every time an agent C connects on the bus, disconnects from the bus, subscribes to a regexp, or unsubscribes to a regexp. When the agent A is stopping, this function is also called inside the agent A for every other agents Ci on the bus, as they are disconnecting. The first 3 parameters are a reference to an array of connected agents Ci, a reference to an array of not connected agents (according to the "-neededApp" argument of the new method / function), a reference to a hash table of connected agents Ci (giving the number of each agent). These 3 parameters are maintained for upwards compatibility but should no more be used, since the following three parameters are much easier to use: the name of an appearing / disapearing or subscribing / unsubscribing agent C, its status either "new" or "died" or "subscribing" or "unsubscribing", and the hostname where this agent C is running / dying OR the subscribed / unsubscribed regexp. If the hostname of this agent C is not known, it will be replaced by its IP address.