connect_timeout returns `Ok(())` on macOS but socket is not connected
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
- #669 de @rootkiller6788 — cerrado sin fusionar
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 52/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- rust
- Área
- networking
Línea de trabajo
Comienza en src/socket.rs, cerca de la ruta rápida alrededor de la línea 217, y reproduce el caso de TCP sobre IPv6 en macOS con la configuración de VPN indicada. Comprueba cómo se gestionan los resultados de connect() sin bloqueo cuando devuelve Ok(()) en lugar de EINPROGRESS, y compara el comportamiento con la ruta existente de Linux. Se considera terminado cuando connect_timeout no informa de éxito mientras peer_addr() sigue devolviendo ENOTCONN.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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?
- Lenguaje dominante
- Rust
- Estrellas
- 885
- Forks
- 328
- Merge medio
- 6 d 12 h
- PR fusionados (30 d)
- 2
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de rust-lang/socket2
-
Commit lockfileAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
rust-lang/socket2#703 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
windows-sys 0.101.0Posiblemente ocupada @xtqqczze la tomó hace 3 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
SockAddr::path_len doesn't bound the length by sun_path: as_pathname panics since #691, as_abstract_namespace slices past itPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
`from_timeval` overflows on a non-normalised `tv_usec`Posiblemente ocupada @pederbe la tomó hace 18 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
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 fieldPosiblemente ocupada @omrzk la tomó hace 28 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
rust-lang/socket2#684 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de rust-lang/socket2
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
infra
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
available bug good first issue tooling
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Nixitov/Riptide-Native#817 ·
Los mantenedores suelen responder en 1 día