ssl:recv/2 has no timeout (no ssl:recv/3)

Abierto
#2,434 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
55/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
erlang
Área
networking

Línea de trabajo

Start in libs/estdlib/src/ssl.erl at ssl:recv/2 and its want_read select notification handling; compare the timeout behavior in AtomVM's gen_tcp or socket APIs and OTP's ssl:recv/3. Done means recv/3 accepts a timeout, recv/2 behaves as an infinite-timeout call, and a timed-out receive cancels its select and returns {error, timeout}.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

ssl:recv/2 (libs/estdlib/src/ssl.erl) waits on want_read with a bare receive for the select notification:

receive
    {'$socket', Socket, select, Ref} -> recv0(...);
    {'$socket', Socket, abort, {Ref, closed}} -> {error, closed}
end

If the peer stops sending but the TCP connection isn't closed (NAT drop, cellular link stall, a server that stops mid-stream), the call never returns. OTP has ssl:recv/3 with a Timeout, and gen_tcp/socket in AtomVM already accept timeouts, but ssl exports only recv/2.

We hit this on ESP32 downloading firmware over HTTPS through a 4G modem: the stream stalled and the process sat in ssl:recv/2 until we added an external watchdog that kills it.

Proposal: add recv/3 with Timeout :: timeout() (recv/2 = recv(S, L, infinity)), with an after clause that cancels the select (socket:nif_select_stop/1 or equivalent) and returns {error, timeout}, as OTP does. Happy to send a PR.

Lenguaje dominante
Erlang
Estrellas
2.3k
Forks
171
Merge medio
5 d 11 h
PR fusionados (30 d)
19

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de atomvm/AtomVM

Todos los issues de atomvm/AtomVM

Issues similares

Más issues de Networking

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.