aboutsummaryrefslogtreecommitdiffstats
path: root/pathod
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2016-06-02 16:08:17 +1200
committerAldo Cortesi <aldo@nullcube.com>2016-06-02 16:08:17 +1200
commit29bcdc82509662d1c016dfd42122331678586d5b (patch)
tree23839af0a44866a4b208c09fb55eadb9ec13e045 /pathod
parentffca395e48d3909c9f588767978d128c1a6529d5 (diff)
downloadmitmproxy-29bcdc82509662d1c016dfd42122331678586d5b.tar.gz
mitmproxy-29bcdc82509662d1c016dfd42122331678586d5b.tar.bz2
mitmproxy-29bcdc82509662d1c016dfd42122331678586d5b.zip
Fix lock over pathod locks
There were basically a nop before... o_O
Diffstat (limited to 'pathod')
-rw-r--r--pathod/pathod.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/pathod/pathod.py b/pathod/pathod.py
index 7795df0e..0449c0c1 100644
--- a/pathod/pathod.py
+++ b/pathod/pathod.py
@@ -353,6 +353,8 @@ class Pathod(tcp.TCPServer):
staticdir=self.staticdir
)
+ self.loglock = threading.Lock()
+
def check_policy(self, req, settings):
"""
A policy check that verifies the request size is within limits.
@@ -403,8 +405,7 @@ class Pathod(tcp.TCPServer):
def add_log(self, d):
if not self.noapi:
- lock = threading.Lock()
- with lock:
+ with self.loglock:
d["id"] = self.logid
self.log.insert(0, d)
if len(self.log) > self.LOGBUF:
@@ -413,17 +414,18 @@ class Pathod(tcp.TCPServer):
return d["id"]
def clear_log(self):
- lock = threading.Lock()
- with lock:
+ with self.loglock:
self.log = []
def log_by_id(self, identifier):
- for i in self.log:
- if i["id"] == identifier:
- return i
+ with self.loglock:
+ for i in self.log:
+ if i["id"] == identifier:
+ return i
def get_log(self):
- return self.log
+ with self.loglock:
+ return self.log
def main(args): # pragma: no cover