From e6c6de18d20bb7b0606878e9a0e705d29ff13059 Mon Sep 17 00:00:00 2001 From: rudolfkoenig Date: Fri, 18 Jan 2019 09:37:05 +0000 Subject: [PATCH] fhem.pl: ignore duplicate uuids in setuuid (Forum #95902) git-svn-id: https://svn.fhem.de/fhem/trunk@18311 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/fhem.pl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fhem/fhem.pl b/fhem/fhem.pl index cd1e1795b..694122748 100755 --- a/fhem/fhem.pl +++ b/fhem/fhem.pl @@ -293,6 +293,7 @@ my %duplicate; # Pool of received msg for multi-fhz/cul setups my @cmdList; # Remaining commands in a chain. Used by sleep my %sleepers; # list of sleepers my %delayedShutdowns; # definitions needing delayed shutdown +my %fuuidHash; # for duplicate checking $init_done = 0; $lastDefChange = 0; @@ -1591,6 +1592,8 @@ CommandSetuuid($$) return "setuuid cannot be used after FHEM is initialized" if($init_done); my @a = split(" ", $param); return "Please define $param first" if(!defined($defs{$a[0]})); + return "setuuid $a[0]: duplicate value, ignoring it" if($fuuidHash{$a[1]}); + $fuuidHash{$a[1]} = $a[1]; $defs{$a[0]}{FUUID} = $a[1]; return undef; } @@ -5853,8 +5856,10 @@ sub genUUID() { srand(gettimeofday()) if(!$srandUsed); $srandUsed = 1; - return sprintf("%08x-f33f-%s-%s-%s", time(), substr(getUniqueId(),-4), + my $uuid = sprintf("%08x-f33f-%s-%s-%s", time(), substr(getUniqueId(),-4), join("",map { unpack "H*", chr(rand(256)) } 1..2), join("",map { unpack "H*", chr(rand(256)) } 1..8)); + $fuuidHash{$uuid} = 1; + return $uuid; } 1;