1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 02:00:45 +00:00

target: Fix deadlock in Target.clear_logcat()

Ensure that only once clear_logcat() call is active at once, and just
ignore reentrant calls.
This commit is contained in:
Douglas Raillard 2021-07-21 13:58:53 +01:00 committed by Marc Bonnici
parent b64ec714a0
commit f523afda95

View File

@ -1759,11 +1759,15 @@ class AndroidTarget(Target):
self.remove(dev_path) self.remove(dev_path)
def clear_logcat(self): def clear_logcat(self):
with self.clear_logcat_lock: locked = self.clear_logcat_lock.acquire(blocking=False)
if locked:
try:
if isinstance(self.conn, AdbConnection): if isinstance(self.conn, AdbConnection):
adb_command(self.adb_name, 'logcat -c', timeout=30, adb_server=self.adb_server) adb_command(self.adb_name, 'logcat -c', timeout=30, adb_server=self.adb_server)
else: else:
self.execute('logcat -c', timeout=30) self.execute('logcat -c', timeout=30)
finally:
self.clear_logcat_lock.release()
def get_logcat_monitor(self, regexps=None): def get_logcat_monitor(self, regexps=None):
return LogcatMonitor(self, regexps) return LogcatMonitor(self, regexps)