summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@felicio.ghostprotocols.net>2015-06-09 16:15:42 -0300
committerArnaldo Carvalho de Melo <acme@felicio.ghostprotocols.net>2015-06-09 16:15:42 -0300
commitc88cc9023068430db3f92919048c47b67c6edcd7 (patch)
tree9daa40aee5160cc2d44f7e2c04bac7bf6a0d0942
parent29fbb6e82357c87be652c6717ef52d808ec0af78 (diff)
downloadtuna-c88cc9023068430db3f92919048c47b67c6edcd7.tar.gz
tuna: Fix race in is_hardirq_handler
It is better to try accessing the fields catching exceptions, as just checking if we have that key is not enough for, right after, that thread having gone away and the populating of that dict entry not finding the file on /proc/PID/. Signed-off-by: Arnaldo Carvalho de Melo <acme@felicio.ghostprotocols.net>
-rwxr-xr-xtuna/tuna.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/tuna/tuna.py b/tuna/tuna.py
index 6cd6bdd..3c30f03 100755
--- a/tuna/tuna.py
+++ b/tuna/tuna.py
@@ -166,10 +166,11 @@ def list_to_cpustring(l):
# FIXME: move to python-linux-procfs
def is_hardirq_handler(self, pid):
PF_HARDIRQ = 0x08000000
- if not self.processes.has_key(pid):
+ try:
+ return int(self.processes[pid]["stat"]["flags"]) & \
+ PF_HARDIRQ and True or False
+ except:
return False
- return int(self.processes[pid]["stat"]["flags"]) & \
- PF_HARDIRQ and True or False
# FIXME: move to python-linux-procfs
def cannot_set_affinity(self, pid):