Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
0ba609dc
Unverified
Commit
0ba609dc
authored
6 years ago
by
Richard van der Hoff
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #3183 from matrix-org/rav/moar_logcontext_leaks
Fix logcontext leaks in rate limiter
parents
2117f843
a7fe62f0
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/util/ratelimitutils.py
+14
-3
14 additions, 3 deletions
synapse/util/ratelimitutils.py
with
14 additions
and
3 deletions
synapse/util/ratelimitutils.py
+
14
−
3
View file @
0ba609dc
...
...
@@ -18,7 +18,10 @@ from twisted.internet import defer
from
synapse.api.errors
import
LimitExceededError
from
synapse.util.async
import
sleep
from
synapse.util.logcontext
import
run_in_background
from
synapse.util.logcontext
import
(
run_in_background
,
make_deferred_yieldable
,
PreserveLoggingContext
,
)
import
collections
import
contextlib
...
...
@@ -176,6 +179,9 @@ class _PerHostRatelimiter(object):
return
r
def
on_err
(
r
):
# XXX: why is this necessary? this is called before we start
# processing the request so why would the request be in
# current_processing?
self
.
current_processing
.
discard
(
request_id
)
return
r
...
...
@@ -187,7 +193,7 @@ class _PerHostRatelimiter(object):
ret_defer
.
addCallbacks
(
on_start
,
on_err
)
ret_defer
.
addBoth
(
on_both
)
return
ret_defer
return
make_deferred_yieldable
(
ret_defer
)
def
_on_exit
(
self
,
request_id
):
logger
.
debug
(
...
...
@@ -197,7 +203,12 @@ class _PerHostRatelimiter(object):
self
.
current_processing
.
discard
(
request_id
)
try
:
request_id
,
deferred
=
self
.
ready_request_queue
.
popitem
()
# XXX: why do we do the following? the on_start callback above will
# do it for us.
self
.
current_processing
.
add
(
request_id
)
deferred
.
callback
(
None
)
with
PreserveLoggingContext
():
deferred
.
callback
(
None
)
except
KeyError
:
pass
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment