diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-01-28 15:26:22 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-01-28 15:26:22 +0100 |
commit | 6a128dde71d925fd4865ebd86855213a429b4729 (patch) | |
tree | 9c35e42da3583e1ec7fa88bb514f50b7feaf51e4 /device/uapi.go | |
parent | 34c047c762c31911333833c56a6dc50c52c84f5f (diff) |
device: do not allow get to run while set runs
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'device/uapi.go')
-rw-r--r-- | device/uapi.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/device/uapi.go b/device/uapi.go index 6f7fb2a..43bb0d6 100644 --- a/device/uapi.go +++ b/device/uapi.go @@ -50,6 +50,9 @@ var byteBufferPool = &sync.Pool{ // IpcGetOperation implements the WireGuard configuration protocol "get" operation. // See https://www.wireguard.com/xplatform/#configuration-protocol for details. func (device *Device) IpcGetOperation(w io.Writer) error { + device.ipcMutex.RLock() + defer device.ipcMutex.RUnlock() + buf := byteBufferPool.Get().(*bytes.Buffer) buf.Reset() defer byteBufferPool.Put(buf) @@ -137,8 +140,8 @@ func (device *Device) IpcGetOperation(w io.Writer) error { // IpcSetOperation implements the WireGuard configuration protocol "set" operation. // See https://www.wireguard.com/xplatform/#configuration-protocol for details. func (device *Device) IpcSetOperation(r io.Reader) (err error) { - device.ipcSetMu.Lock() - defer device.ipcSetMu.Unlock() + device.ipcMutex.Lock() + defer device.ipcMutex.Unlock() defer func() { if err != nil { |