connect_timeout returns `Ok(())` on macOS but socket is not connected
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
- #669 von @rootkiller6788 — ohne Merge geschlossen
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 52/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Ruhig
- Tech-Stack
- rust
- Bereich
- networking
Rechercherichtung
Beginne in src/socket.rs beim Fast Path in der Nähe von Zeile 217 und reproduziere den IPv6-TCP-Fall unter macOS mit dem gemeldeten VPN-Setup. Prüfe, wie die Ergebnisse von nicht blockierendem connect() behandelt werden, wenn es Ok(()) statt EINPROGRESS zurückgibt, und vergleiche das Verhalten mit dem bestehenden Linux-Pfad. Als erledigt gilt dies, wenn connect_timeout keinen Erfolg meldet, während peer_addr() weiterhin ENOTCONN zurückgibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
I am observing a case on macOS where connect_timeout returns Ok(()) but the socket is not actually connected: peer_addr() (getpeername) immediately returns ENOTCONN.
Minimal reproducer:
use socket2::{Domain, Protocol, SockAddr, Socket, Type};
use std::{net::SocketAddr, time::Duration};
fn main() {
let remote_addr = "[<remote-ipv6>]:443"
.parse::<SocketAddr>()
.unwrap();
let socket = Socket::new(Domain::IPV6, Type::STREAM, Some(Protocol::TCP)).unwrap();
socket
.connect_timeout(&SockAddr::from(remote_addr), Duration::from_secs(10))
.unwrap();
println!("connect_timeout returned Ok(())");
println!("peer_addr: {:?}", socket.peer_addr());
}
Output on the affected machine:
Socket connected
Err(Os { code: 57, kind: NotConnected, message: "Socket is not connected" })
Environment
- macOS
15.7.3(aarch64) socket2 0.6.3- IPv6 TCP socket connecting to a remote server
- The machine has a global IPv6 address and a default IPv6 route via the physical interface
- A VPN is active that captures IPv4 traffic (via a utun interface) but does not carry IPv6
In that particular environment, decomposing Socket::connect_timeout step by step the issue is in the fast path (https://github.com/rust-lang/socket2/blob/master/src/socket.rs#L217). The non-blocking connect() call returns Ok(0) instead of Err(EINPROGRESS):
set_nonblocking(true)
connect() → Ok(()) ← should be Err(EINPROGRESS) for a remote TCP address
set_nonblocking(false)
// connect_timeout returns Ok(()) here, poll_connect is never called
This happens consistently (10/10 attempts) on this machine when the VPN is active.
The same network configuration on Linux works correctly: connect() returns EINPROGRESS in both cases (with or without VPN)
There's something I am missing about how connect_timeout should be used?
- Vorherrschende Sprache
- Rust
- Sterne
- 885
- Forks
- 328
- Ø Merge
- 6 T. 12 Std.
- Gemergte PRs (30 T.)
- 2
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus rust-lang/socket2
-
Commit lockfileOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
rust-lang/socket2#703 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
windows-sys 0.101.0Evtl. vergeben @xtqqczze hat das vor 3 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
Maintainer antworten meist innerhalb von 1 Tag
-
SockAddr::path_len doesn't bound the length by sun_path: as_pathname panics since #691, as_abstract_namespace slices past itEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
`from_timeval` overflows on a non-normalised `tv_usec`Evtl. vergeben @pederbe hat das vor 18 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
Build fails on 32-bit glibc (i686, armv7) with libc's `--cfg=libc_unstable_time64`: `tv_usec` is cast to `suseconds_t` (i32) for an i64 fieldEvtl. vergeben @omrzk hat das vor 28 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
rust-lang/socket2#684 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in rust-lang/socket2
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
infra
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag
-
available bug good first issue tooling
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Nixitov/Riptide-Native#817 ·
Maintainer antworten meist innerhalb von 1 Tag