MCPcopy
hub / github.com/WireGuard/wireguard-go / Close

Method Close

device/device.go:370–400  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

368}
369
370func (device *Device) Close() {
371 device.state.Lock()
372 defer device.state.Unlock()
373 device.ipcMutex.Lock()
374 defer device.ipcMutex.Unlock()
375 if device.isClosed() {
376 return
377 }
378 device.state.state.Store(uint32(deviceStateClosed))
379 device.log.Verbosef("Device closing")
380
381 device.tun.device.Close()
382 device.downLocked()
383
384 // Remove peers before closing queues,
385 // because peers assume that queues are active.
386 device.RemoveAllPeers()
387
388 // We kept a reference to the encryption and decryption queues,
389 // in case we started any new peers that might write to them.
390 // No new peers are coming; we are done with these queues.
391 device.queue.encryption.wg.Done()
392 device.queue.decryption.wg.Done()
393 device.queue.handshake.wg.Done()
394 device.state.stopping.Wait()
395
396 device.rate.limiter.Close()
397
398 device.log.Verbosef("Device closed")
399 close(device.closed)
400}
401
402func (device *Device) Wait() chan struct{} {
403 return device.closed

Callers 1

RoutineReadFromTUNMethod · 0.95

Implementers 4

NativeTuntun/tun_linux.go
netTuntun/netstack/tun.go
chTuntun/tuntest/tuntest.go
fakeTUNDeviceSizeddevice/device_test.go

Calls 5

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

Tested by

no test coverage detected