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.
()
| 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. |
| 175 | func (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. |
no test coverage detected