Skip to content

Commit d06cfdd

Browse files
committed
rtc: don't put ffi_drop_handle side effect inside assert
With python -O asserts are stripped, which would skip the drop and leak the native handle. Call drop_handle unconditionally and assert the result separately.
1 parent 5472a7c commit d06cfdd

21 files changed

Lines changed: 60 additions & 7 deletions

livekit-protocol/protocol

Submodule protocol updated 83 files

livekit-rtc/livekit/rtc/_ffi_client.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ def dispose(self) -> None:
8585
self._disposed = True
8686
ffi = FfiClient._owned_instance()
8787
if ffi is not None:
88-
assert ffi._ffi_lib.livekit_ffi_drop_handle(ctypes.c_uint64(self.handle))
88+
dropped = ffi._ffi_lib.livekit_ffi_drop_handle(ctypes.c_uint64(self.handle))
89+
assert dropped
8990

9091
def __repr__(self) -> str:
9192
return f"FfiHandle({self.handle})"
@@ -232,10 +233,8 @@ def instance(cls) -> "FfiClient":
232233

233234
@classmethod
234235
def _owned_instance(cls) -> Optional["FfiClient"]:
235-
# Cleanup/GC paths (FfiHandle.dispose, *Stream.__del__, Room.__del__)
236-
# use this instead of `instance` so they no-op in a fork child rather
237-
# than raising the fork guard, which __del__ would surface on stderr as
238-
# "Exception ignored in...". A child must not touch the inherited FFI.
236+
# the client only if this process created it; cleanup paths use it to
237+
# no-op in fork children instead of touching inherited FFI/locks
239238
inst = cls._instance
240239
return inst if inst is not None and inst._pid == os.getpid() else None
241240

livekit-rtc/rust-sdks

Submodule rust-sdks updated 275 files
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:5bd3c81911b0fbd235c8f07ac9f3eab50fa11610caf3f3823cd9dd8a1eb5dc9e
3+
size 582764
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:e17d7f0085d85cb1d3be056aaf3b4eb32b3314c58dd3835afcdcaad418dd3854
3+
size 582764
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:df9c739d143362433f0173cb85f7bb4ac6fc74c58d55ae95c4d02f6dda9a62f3
3+
size 581842
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:30eb1c9ad66f615dbf1cbcf22848f00be8663877ed16fb673f5a4abbe79fb5a0
3+
size 582764
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:7478cbba3cfe180fbb6776f2b439c5e6e343a78e47f5a36c7fa2dd9c6377a79a
3+
size 582764
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:60e2072e4ffba25a0a87a99c73dd0e1dacda36edebc8b503792ed7c833161cf5
3+
size 581842
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:660a1a2622d53d681db7a34b6dc0375ee56963de08d0730552c2454a69ae6c1b
3+
size 582764

0 commit comments

Comments
 (0)