summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--changelog.d/7930.feature1
-rw-r--r--synapse/federation/transport/server.py6
2 files changed, 7 insertions, 0 deletions
diff --git a/changelog.d/7930.feature b/changelog.d/7930.feature
new file mode 100644
index 0000000000..a27e4812da
--- /dev/null
+++ b/changelog.d/7930.feature
@@ -0,0 +1 @@
+Abort federation requests where the client disconnects before the ratelimiter expires.
diff --git a/synapse/federation/transport/server.py b/synapse/federation/transport/server.py
index 24f7d4b3bc..5e111aa902 100644
--- a/synapse/federation/transport/server.py
+++ b/synapse/federation/transport/server.py
@@ -338,6 +338,12 @@ class BaseFederationServlet(object):
                 if origin:
                     with ratelimiter.ratelimit(origin) as d:
                         await d
+                        if request._disconnected:
+                            logger.warning(
+                                "client disconnected before we started processing "
+                                "request"
+                            )
+                            return -1, None
                         response = await func(
                             origin, content, request.args, *args, **kwargs
                         )