aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy/controller.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2017-12-29 22:44:18 +0100
committerThomas Kriechbaumer <thomas@kriechbaumer.name>2017-12-29 22:56:29 +0100
commit62326227740d3808c0886ed381cb976a6b2f8b03 (patch)
treebb86ed2d55822470608568115ce41ce51c6edba8 /mitmproxy/controller.py
parent59c277effd016fdf771a65aaaa87526ff5fe869e (diff)
downloadmitmproxy-62326227740d3808c0886ed381cb976a6b2f8b03.tar.gz
mitmproxy-62326227740d3808c0886ed381cb976a6b2f8b03.tar.bz2
mitmproxy-62326227740d3808c0886ed381cb976a6b2f8b03.zip
fix Flow.kill behaviour
This now just sets a kill reply instead of committing directly. First, this seems like the more sane thing to do. Second, we have an iffy race condition where we call Reply.commit() before the addonmanager finishes its invocation, the proxy thread then progresses and sets a new flow.reply attribute, and the addonmanager then gets confused when finishing. This commit doesn't fix that, but mitigates it for Flow.kill which is now committed by the addonmanager.
Diffstat (limited to 'mitmproxy/controller.py')
-rw-r--r--mitmproxy/controller.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/mitmproxy/controller.py b/mitmproxy/controller.py
index 63117ef0..f39c1b24 100644
--- a/mitmproxy/controller.py
+++ b/mitmproxy/controller.py
@@ -105,16 +105,16 @@ class Reply:
self.q.put(self.value)
def ack(self, force=False):
- if self.state not in {"start", "taken"}:
- raise exceptions.ControlException(
- "Reply is {}, but expected it to be start or taken.".format(self.state)
- )
self.send(self.obj, force)
def kill(self, force=False):
self.send(exceptions.Kill, force)
def send(self, msg, force=False):
+ if self.state not in {"start", "taken"}:
+ raise exceptions.ControlException(
+ "Reply is {}, but expected it to be start or taken.".format(self.state)
+ )
if self.has_message and not force:
raise exceptions.ControlException("There is already a reply message.")
self.value = msg