Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions host/libcontainer_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,12 @@ type LibcontainerBackend struct {
envMtx sync.RWMutex
defaultEnv map[string]string

discoverdConfigured chan struct{}
networkConfigured chan struct{}
// discoverdConfigured is closed once discoverd has been configured via
// SetDefaultEnv. discoverdConfiguredSet is guarded by envMtx and tracks
// whether the channel has already been closed to prevent a double close.
discoverdConfigured chan struct{}
discoverdConfiguredSet bool
networkConfigured chan struct{}

globalStateMtx sync.Mutex
globalState *libcontainerGlobalState
Expand Down Expand Up @@ -419,11 +423,14 @@ func (l *LibcontainerBackend) ServeDHCP(p dhcp.Packet, msgType dhcp.MessageType,

func (l *LibcontainerBackend) SetDefaultEnv(k, v string) {
l.envMtx.Lock()
defer l.envMtx.Unlock()
l.defaultEnv[k] = v
l.envMtx.Unlock()
if k == "DISCOVERD" {
l.discoverdClient = discoverd.NewClientWithURL(v)
close(l.discoverdConfigured)
if !l.discoverdConfiguredSet {
l.discoverdConfiguredSet = true
close(l.discoverdConfigured)
}
}
}

Expand Down
Loading