Skip to content

added code to avoid answers / offers race on rust client, #915

Open
xianshijing-lk wants to merge 1 commit intomainfrom
sxian/CLT-2585/avoid_offer_answer_races
Open

added code to avoid answers / offers race on rust client, #915
xianshijing-lk wants to merge 1 commit intomainfrom
sxian/CLT-2585/avoid_offer_answer_races

Conversation

@xianshijing-lk
Copy link
Contributor

similar t JS solution

Copy link
Contributor

@ladvoc ladvoc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ✅, just a few minor questions/suggestions

})
// Prefer compressed payload when present.
// If decompression fails, only fall back to plain payload when it is non-empty.
let payload = if !rpc_request.compressed_payload.is_empty() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Was adding this code in this PR intentional?

let latest_offer_id = self.latest_offer_id.load(Ordering::Acquire);
let latest_answer_id = self.latest_answer_id.load(Ordering::Acquire);
if answer_id > 0 && (answer_id < latest_offer_id || answer_id <= latest_answer_id) {
log::warn!(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Should this be logged at warn level?

/// Mapping from SDP mid to track ID, used for track resolution in single PC mode
mid_to_track_id: Mutex<HashMap<String, String>>,
/// Offer/answer ordering guards for single-PC churn protection.
next_offer_id: AtomicU32,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: I don’t have a strong opinion here, but since this adds a bunch of related fields, it might make sense to group them into their own struct (e.g., SDPExchangeState) and include that here instead. This would add no overhead and could help clarify that these fields are conceptually related.

subscriber_pc,
single_pc_mode,
mid_to_track_id: Mutex::new(HashMap::new()),
next_offer_id: AtomicU32::new(1),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you apply the suggestion from above, you can implement default on the struct and initialize here like this:

sdp_exchange_state: SdpExchangeState {
    next_offer_id: AtomicU32::new(1),
    ..Default::default()
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants