mirror of
https://git.zx2c4.com/wireguard-go
synced 2024-11-15 09:15:14 +01:00
device: serialize access to IpcSetOperation
Interleaves IpcSetOperations would spell trouble. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
parent
a9ce4b762c
commit
cecb41515d
@ -23,6 +23,7 @@ type Device struct {
|
|||||||
isUp AtomicBool // device is (going) up
|
isUp AtomicBool // device is (going) up
|
||||||
isClosed AtomicBool // device is closed? (acting as guard)
|
isClosed AtomicBool // device is closed? (acting as guard)
|
||||||
log *Logger
|
log *Logger
|
||||||
|
ipcSetMu sync.Mutex // serializes UAPI set operations
|
||||||
|
|
||||||
// synchronized resources (locks acquired in order)
|
// synchronized resources (locks acquired in order)
|
||||||
|
|
||||||
|
@ -121,6 +121,9 @@ func (device *Device) IpcGetOperation(w io.Writer) error {
|
|||||||
// IpcSetOperation implements the WireGuard configuration protocol "set" operation.
|
// IpcSetOperation implements the WireGuard configuration protocol "set" operation.
|
||||||
// See https://www.wireguard.com/xplatform/#configuration-protocol for details.
|
// See https://www.wireguard.com/xplatform/#configuration-protocol for details.
|
||||||
func (device *Device) IpcSetOperation(r io.Reader) (err error) {
|
func (device *Device) IpcSetOperation(r io.Reader) (err error) {
|
||||||
|
device.ipcSetMu.Lock()
|
||||||
|
defer device.ipcSetMu.Unlock()
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
device.log.Error.Println(err)
|
device.log.Error.Println(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user