Skip to content

Commit

Permalink
fix discovery Registry w/ no expiration
Browse files Browse the repository at this point in the history
  • Loading branch information
danjacques committed Apr 19, 2018
1 parent b78d96d commit 4547c71
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions discovery/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,13 @@ func (reg *Registry) Observe(dh *protocol.DiscoveryHeaders) (d device.D, isNew b
}

// Observe the entry and update its timeout and headers.
e.updateState(now, &discoveredDeviceState{
dh: dh,
expires: now.Add(reg.Expiration),
})
st := discoveredDeviceState{
dh: dh,
}
if reg.Expiration > 0 {
st.expires = now.Add(reg.Expiration)
}
e.updateState(now, &st)

d = e.device
return
Expand Down Expand Up @@ -179,7 +182,9 @@ type registryEntry struct {

func (e *registryEntry) updateState(now time.Time, st *discoveredDeviceState) {
e.device.UpdateHeaders(now, st.dh)
e.updateExpirationC <- st.expires
if !st.expires.IsZero() {
e.updateExpirationC <- st.expires
}
}

func (e *registryEntry) manageEntryLifecycle() {
Expand Down

0 comments on commit 4547c71

Please sign in to comment.