Ensure we always drop the federation inbound lock (#10336)

pull/10355/head
Erik Johnston 2021-07-09 10:16:54 +01:00 committed by GitHub
parent 974261cd81
commit 1579fdd54a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

1
changelog.d/10336.bugfix Normal file
View File

@ -0,0 +1 @@
Fix bug where inbound federation in a room could be delayed due to not correctly dropping a lock. Introduced in v1.37.1.

View File

@ -949,6 +949,7 @@ class FederationServer(FederationBase):
room_id, room_version room_id, room_version
) )
if not next: if not next:
await lock.release()
return return
origin, event = next origin, event = next

View File

@ -310,14 +310,25 @@ class Lock:
_excinst: Optional[BaseException], _excinst: Optional[BaseException],
_exctb: Optional[TracebackType], _exctb: Optional[TracebackType],
) -> bool: ) -> bool:
await self.release()
return False
async def release(self) -> None:
"""Release the lock.
This is automatically called when using the lock as a context manager.
"""
if self._dropped:
return
if self._looping_call.running: if self._looping_call.running:
self._looping_call.stop() self._looping_call.stop()
await self._store._drop_lock(self._lock_name, self._lock_key, self._token) await self._store._drop_lock(self._lock_name, self._lock_key, self._token)
self._dropped = True self._dropped = True
return False
def __del__(self) -> None: def __del__(self) -> None:
if not self._dropped: if not self._dropped:
# We should not be dropped without the lock being released (unless # We should not be dropped without the lock being released (unless