[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Only check proc path properties once
commit b40c605e857e0ef2b762bcb3fe5fec67e8957c8c
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Sun Sep 24 10:46:27 2017 -0700
Only check proc path properties once
Silly to do these two on every line of the proc file.
---
stem/util/proc.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/stem/util/proc.py b/stem/util/proc.py
index 51e40a13..59681160 100644
--- a/stem/util/proc.py
+++ b/stem/util/proc.py
@@ -375,14 +375,15 @@ def connections(pid = None, user = None):
if proc_file_path.endswith('6') and not os.path.exists(proc_file_path):
continue # ipv6 proc contents are optional
+ protocol = proc_file_path[10:].rstrip('6') # 'tcp' or 'udp'
+ is_ipv6 = proc_file_path.endswith('6')
+
try:
with open(proc_file_path, 'rb') as proc_file:
proc_file.readline() # skip the first line
for line in proc_file:
_, l_addr, f_addr, status, _, _, _, uid, _, inode = line.split()[:10]
- protocol = proc_file_path[10:].rstrip('6') # 'tcp' or 'udp'
- is_ipv6 = proc_file_path.endswith('6')
if inodes and inode not in inodes:
continue
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits