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

Aperta
#2,434 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
erlang
Ambito
networking

Direzione di ricerca

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}.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Erlang
Stelle
2.3k
Fork
171
Merge medio
5g 11h
PR unite (30g)
19

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di atomvm/AtomVM

Tutte le issue di atomvm/AtomVM

Issue simili

Altre issue su Networking

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.