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.
This commit is contained in:
AAA committed 2026-11-26 05:37:13 +08:00
1 parent 26c407fc64
commit 0cdfe8bdfc
1 file changed
+3
@@ -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