@@ -359,18 +359,23 @@ func IMEXDaemonUpdateLoopWithIPs(ctx context.Context, controller *Controller, cl
359359 }
360360}
361361
362- func shouldSendSIGUSR1 (oldIPs , newIPs map [string ]struct {}, updated , fresh bool ) bool {
362+ // shouldSendSIGUSR1 determines whether the IMEX daemon should be
363+ // signaled to re-resolve and reconnect to peers.
364+ //
365+ // updated indicates whether the DNS/IP mapping actually changed.
366+ // fresh indicates whether the IMEX daemon process was just started.
367+ //
368+ // The signal is sent only when:
369+ // - the mapping was updated,
370+ // - the process is not fresh, and
371+ // - at least one new IP (peer) was added.
372+ func shouldSendSIGUSR1 (oldIPs , newIPs IPSet , updated , fresh bool ) bool {
363373 if ! updated || fresh {
364374 return false
365375 }
366376
367- for ip := range newIPs {
368- if _ , existed := oldIPs [ip ]; ! existed {
369- return true
370- }
371- }
372-
373- return false
377+ added , _ := oldIPs .Diff (newIPs )
378+ return len (added ) > 0
374379}
375380
376381// IMEXDaemonUpdateLoopWithDNSNames reacts to ComputeDomain status changes by
@@ -412,7 +417,7 @@ func IMEXDaemonUpdateLoopWithDNSNames(ctx context.Context, controller *Controlle
412417 // - the process is fresh (has newly been started), or
413418 // - this was a noop update, or
414419 // - no new peers were added (i.e. the update only removes nodes or keeps the set unchanged).
415- if ! shouldSendSIGUSR1 (oldIPs , dnsNameManager .ipToDNSName , updated , fresh ) {
420+ if ! shouldSendSIGUSR1 (IPSet ( oldIPs ), IPSet ( dnsNameManager .ipToDNSName ) , updated , fresh ) {
416421 break
417422 }
418423
0 commit comments