Skip to content

Commit b7cd547

Browse files
raggizx2c4
authored andcommitted
device: wait for and lock ipc operations during close
If an IPC operation is in flight while close starts, it is possible for both processes to deadlock. Prevent this by taking the IPC lock at the start of close and for the duration. Signed-off-by: James Tucker <[email protected]> Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent 052af4a commit b7cd547

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

device/device.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,8 @@ func (device *Device) RemoveAllPeers() {
368368
}
369369

370370
func (device *Device) Close() {
371+
device.ipcMutex.Lock()
372+
defer device.ipcMutex.Unlock()
371373
device.state.Lock()
372374
defer device.state.Unlock()
373375
if device.isClosed() {

0 commit comments

Comments
 (0)