summaryrefslogtreecommitdiff
path: root/Ivy.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Ivy.pm')
-rw-r--r--Ivy.pm39
1 files changed, 18 insertions, 21 deletions
diff --git a/Ivy.pm b/Ivy.pm
index 143dda3..5f0b145 100644
--- a/Ivy.pm
+++ b/Ivy.pm
@@ -46,7 +46,7 @@ use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK);
# to compute the VERSION from the CVS tag (or if no tag, as the cvs file revision)
my $TAG= q$Name$;
my $REVISION = q$Revision$ ;
-$VERSION = '1.44' ; # for Makefile.PL
+$VERSION = '1.46' ; # for Makefile.PL
($VERSION) = $TAG =~ /^\D*([\d_]+)/ ;
if (defined $VERSION and $VERSION ne "_") {
$VERSION =~ s/_/\./g;
@@ -552,7 +552,7 @@ sub new ($%)
$self->[bufEmiByCnnx] = {};
# identifiant unique
- $self->[uuid] = sprintf ("%d%d", time(), rand()*1e15);
+ $self->[uuid] = sprintf ("%d%d", time(), rand()*(2**31));
# queue de gestion des pings :
# clef : socket fd, valeur :liste [timestamp, machine:port, callBack]
@@ -1327,17 +1327,19 @@ sub _getBonjour ($)
# on verifie qu'on ne se repond pas et qu'on ne
# se reconnecte pas a un process deja connecte
if (exists ($self->[cnnxion]{"$addr:$peerPort"})) {
-# print "DBG> bonjour de $peerName:$peerPort : DEJA CONNECTE\n" ;
+# print "DBG> from $self->[appName] DISCARD bonjour de $peerName:$peerPort [$udpAppName]: DEJA CONNECTE\n" ;
return ;
} elsif ((defined $uuid) && ($uuid eq $self->[uuid])) {
-# print "DBG> bonjour de $peerName:$peerPort : $uuid c'est MOI\n" ;
+# print "DBG> from $self->[appName] DISCARD bonjour de $peerName:$peerPort [$udpAppName]: $uuid c'est MOI\n" ;
return;
} elsif ((defined $uuid) && (exists ($self->[connectedUuid]->{$uuid}))) {
-# print "DBG> bonjour de $peerName:$peerPort:$uuid DEJA CONNECTE\n" ;
+# print "DBG> from $self->[appName] DISCARD bonjour de $peerName:$peerPort:$uuid [$udpAppName] DEJA CONNECTE\n" ;
+ return;
} else {
# print "DBG> reception de $peerName : bonjour $udpAppName:$peerPort" ;
# print " uuid=$uuid" if (defined $uuid);
# print ("\n");
+# print "DBG> from $self->[appName] ACCEPT bonjour de $peerName:$peerPort:$uuid [$udpAppName]\n" ;
$self->[connectedUuid]->{$uuid} = 1 if (defined $uuid);
}
@@ -1457,6 +1459,7 @@ sub _getMessages ($$)
$peerPort = $appSock->peerport() ;
$senderName = $self->[cnnxion]{"$addr:$peerPort"} ;
$senderName = "NONAME" unless $senderName;
+ $senderName =~ s/^\004//g;
# my @messages = split ('\n', $$bufferRef) ;
# $$bufferRef = ($$bufferRef =~ /\n$/) ? '': pop (@messages) ;
@@ -1483,7 +1486,6 @@ sub _getMessages ($$)
my $cb = shift @cb;
# cleaning $sendername with previous \004 used for connection status
- $senderName = $0 if ($senderName =~ /\004(.*)/);
# bindRegexp avancé : on envoie une liste nom adresse port au lieu du nom
$senderName = [$senderName, _getHostByAddr ($addr), $peerPort]
if ($self->[recCbList][$id]->[2] == CALL_BY_REF);
@@ -1523,13 +1525,12 @@ sub _getMessages ($$)
# fois pour toute, et ainsi optimiser la vitesse de
# filtrage des messages a envoyer
# print "DBG> REGEXP from $senderName '$id' '$valeurs'\n";
+ my $host = _getHostByAddr ($addr);
if ($self->_toBePruned ($senderName, $valeurs)) {
- &_scanConnStatus ($self, $senderName, 'filtered',
- join (':', _getHostByAddr ($addr), $peerPort), $valeurs);
+ &_scanConnStatus ($self, $senderName, 'filtered', "$host:$peerPort" , $valeurs);
next;
} else {
- &_scanConnStatus ($self, $senderName, 'subscribing',
- join (':', _getHostByAddr ($addr), $peerPort), $valeurs);
+ &_scanConnStatus ($self, $senderName, 'subscribing', "$host:$peerPort" , $valeurs);
}
# on affecte la nouvelle regexp a un id
$self->[sendRegListSrc]{$appSock}->[$id] = $valeurs;
@@ -1568,13 +1569,9 @@ sub _getMessages ($$)
# on vire la regexp des regexps verifiées
$self->[sendRegList]{$appSock}->[$id] = undef ;
my $regexp = $self->[sendRegListSrc]{$appSock}->[$id];
- # cleaning $sendername with previous \004 used for connection status
- if ($senderName =~ /\004(.*)/) {
- $senderName = $0;
- }
$self->[sendRegListSrc]{$appSock}->[$id] = undef;
- &_scanConnStatus ($self, $senderName, 'unsubscribing',
- join (':', _getHostByAddr ($addr), $peerPort), $regexp);
+ my $host = _getHostByAddr ($addr);
+ &_scanConnStatus ($self, $senderName, 'unsubscribing', "$host:$peerPort" , $regexp);
}
elsif ($type == ENDREGEXP) { # E N D R E G E X P
# on envoie le message ready uniquement a celui qui nous
@@ -1582,9 +1579,8 @@ sub _getMessages ($$)
$self->_sendMsgTo ($appSock, \$self->[messWhenReady]);
# on passe de l'etat Connecte a l'etat Ready
- $self->[cnnxion]{"$addr:$peerPort"} =~ s/^\004//;
+ $self->[cnnxion]{"$addr:$peerPort"} =~ s/^\004//g;
$senderName = $self->[cnnxion]{"$addr:$peerPort"};
-
unless (exists $self->[appliList]{$senderName}) {
$self->[appliList]{$senderName} = [$appSock];
}
@@ -2161,10 +2157,11 @@ sub _getNameByFileDes ($$)
sub _getHostByAddr ($)
{
my $addr = shift;
- return $hostNameByAddr{$addr} if (exists $hostNameByAddr{$addr}) ;
- my $peerName = gethostbyaddr ($addr, AF_INET) || inet_ntoa($addr);
- return ($hostNameByAddr{$addr}= $peerName);
+ $hostNameByAddr{$addr} = gethostbyaddr ($addr, AF_INET) || inet_ntoa($addr)
+ unless exists $hostNameByAddr{$addr};
+
+ return $hostNameByAddr{$addr};
}