MCPcopy Create free account
hub / github.com/encodeous/nylon / upLocked

Method upLocked

polyamide/device/device.go:175–196  ·  view source on GitHub ↗

upLocked attempts to bring the device up and reports whether it succeeded. The caller must hold device.state.mu and is responsible for updating device.state.state.

()

Source from the content-addressed store, hash-verified

173// upLocked attempts to bring the device up and reports whether it succeeded.
174// The caller must hold device.state.mu and is responsible for updating device.state.state.
175func (device *Device) upLocked() error {
176 if err := device.BindUpdate(); err != nil {
177 device.Log.Errorf("Unable to update bind: %v", err)
178 return err
179 }
180
181 // The IPC set operation waits for peers to be created before calling Start() on them,
182 // so if there's a concurrent IPC set request happening, we should wait for it to complete.
183 device.ipcMutex.Lock()
184 defer device.ipcMutex.Unlock()
185 device.IpcHandler = make(map[string]func(*bufio.ReadWriter) error)
186
187 device.peers.RLock()
188 for _, peer := range device.peers.keyMap {
189 peer.Start()
190 if peer.persistentKeepaliveInterval.Load() > 0 {
191 peer.SendKeepalive()
192 }
193 }
194 device.peers.RUnlock()
195 return nil
196}
197
198// downLocked attempts to bring the device down.
199// The caller must hold device.state.mu and is responsible for updating device.state.state.

Callers 1

changeStateMethod · 0.95

Implementers 4

NativeTunpolyamide/tun/tun_linux.go
netTunpolyamide/tun/netstack/tun.go
chTunpolyamide/tun/tuntest/tuntest.go
fakeTUNDeviceSizedpolyamide/device/device_test.go

Calls 3

BindUpdateMethod · 0.95
SendKeepaliveMethod · 0.80
StartMethod · 0.65

Tested by

no test coverage detected