Skip to content

Commit

Permalink
Merge pull request #1198 from Bastian-Krause/bst/udev-mux-race
Browse files Browse the repository at this point in the history
udev/resource: fix mux device race condition leading to outdated control/disk paths
  • Loading branch information
jluebbe committed Jun 7, 2023
2 parents 0a19c6c + 029e60b commit 57f07cf
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions labgrid/resource/udev.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,15 +467,17 @@ def avail(self, prop):
# paths are available.
def poll(self):
super().poll()
if self.device is not None and not self.avail:
for child in self.device.parent.children:
if child.subsystem == 'block' and child.device_type == 'disk':
self.disk_path = child.device_node
self.control_serial = self.device.properties.get('ID_SERIAL_SHORT')

def update(self):
super().update()
if self.device is None:
self.disk_path = None
self.control_serial = None
else:
if not self.avail:
for child in self.device.parent.children:
if child.subsystem == 'block' and child.device_type == 'disk':
self.disk_path = child.device_node
self.control_serial = self.device.properties.get('ID_SERIAL_SHORT')

@property
def path(self):
Expand Down Expand Up @@ -510,16 +512,18 @@ def avail(self, prop):
# paths are available.
def poll(self):
super().poll()
if self.device is not None and not self.avail:
for child in self.device.children:
if child.subsystem == 'block' and child.device_type == 'disk':
self.disk_path = child.device_node
elif child.subsystem == 'scsi_generic':
self.control_path = child.device_node

def update(self):
super().update()
if self.device is None:
self.control_path = None
self.disk_path = None
else:
if not self.avail:
for child in self.device.children:
if child.subsystem == 'block' and child.device_type == 'disk':
self.disk_path = child.device_node
elif child.subsystem == 'scsi_generic':
self.control_path = child.device_node

@property
def path(self):
Expand Down

0 comments on commit 57f07cf

Please sign in to comment.