From 0cdfe8bdfc4f6423156931bed96cd200d45c349f Mon Sep 17 00:00:00 2001 From: AAA <35992542+TNTcraftHIM@users.noreply.github.com> Date: Thu, 26 Nov 2026 05:37:13 +0800 Subject: [PATCH] fix(native): close a transport before its last drain reads consent Since the recovery change the drain fails an established transport that has no send consent. close() disconnects the SDK and then drains, and a disconnected SDK has no consent, so every orderly close of an established transport emitted Failed first. A local input then ended with local_input_failed instead of Ok, and two local-input tests failed. The transport is now marked Closed before it disconnects the SDK. The state says what it is, fail() returns by its own guard and no event is emitted. --- prototype/channel-native/src/peer/transport.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/prototype/channel-native/src/peer/transport.rs b/prototype/channel-native/src/peer/transport.rs index 8f26a1835..a80d0df98 100644 --- a/prototype/channel-native/src/peer/transport.rs +++ b/prototype/channel-native/src/peer/transport.rs @@ -1886,6 +1886,9 @@ impl Engine { while self.turn_setup.try_recv().is_ok() {} self.close_turn(); self.discovery_routes.clear(); + // Closed before the last drain: an SDK we disconnected has no send consent, + // and that must not be read as a failed path. + self.state.store(PeerState::Closed as u8, Ordering::Release); self.rtc.disconnect(); self.drain(); self.udp_send_failures