Skip to content

Commit

Permalink
Fix RPC invocation race condition (livekit#565)
Browse files Browse the repository at this point in the history
* Fix race condition in rpc invocation

* nanpa

* fix

* nanpa

* cgo

* sm
  • Loading branch information
bcherry authored and root committed Feb 19, 2025
1 parent bbe0b0c commit b072c16
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions .nanpa/rpc-race.kdl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
patch package="livekit-ffi" type="fixed" "Fix RPC invocation race bug"
4 changes: 2 additions & 2 deletions livekit-ffi/src/server/participant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ async fn forward_rpc_method_invocation(
let (tx, rx) = oneshot::channel();
let invocation_id = server.next_id();

room.store_rpc_method_invocation_waiter(invocation_id, tx);

let _ = server.send_event(proto::ffi_event::Message::RpcMethodInvocation(
proto::RpcMethodInvocationEvent {
local_participant_handle: local_participant_handle as u64,
Expand All @@ -152,8 +154,6 @@ async fn forward_rpc_method_invocation(
},
));

room.store_rpc_method_invocation_waiter(invocation_id, tx);

rx.await.unwrap_or_else(|_| {
Err(RpcError {
code: RpcErrorCode::ApplicationError as u32,
Expand Down

0 comments on commit b072c16

Please # to comment.