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

Method Close

polyamide/device/device.go:389–419  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

387}
388
389func (device *Device) Close() {
390 device.state.Lock()
391 defer device.state.Unlock()
392 device.ipcMutex.Lock()
393 defer device.ipcMutex.Unlock()
394 if device.isClosed() {
395 return
396 }
397 device.state.state.Store(uint32(deviceStateClosed))
398 device.Log.Verbosef("Device closing")
399
400 device.tun.device.Close()
401 device.downLocked()
402
403 // Remove peers before closing queues,
404 // because peers assume that queues are active.
405 device.RemoveAllPeers()
406
407 // We kept a reference to the encryption and decryption queues,
408 // in case we started any new peers that might write to them.
409 // No new peers are coming; we are done with these queues.
410 device.queue.encryption.wg.Done()
411 device.queue.decryption.wg.Done()
412 device.queue.handshake.wg.Done()
413 device.state.stopping.Wait()
414
415 device.rate.limiter.Close()
416
417 device.Log.Verbosef("Device closed")
418 close(device.closed)
419}
420
421func (device *Device) Wait() chan struct{} {
422 return device.closed

Callers 1

RoutineReadFromTUNMethod · 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 5

isClosedMethod · 0.95
downLockedMethod · 0.95
RemoveAllPeersMethod · 0.95
CloseMethod · 0.65
WaitMethod · 0.45

Tested by

no test coverage detected