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

Đang mở
#2,434 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
55/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
erlang
Lĩnh vực
networking

Hướng nghiên cứu

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

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Erlang
Star
2.3k
Fork
171
Merge trung bình
5 ngày 11 giờ
Pull request đã merge (30 ngày)
19

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của atomvm/AtomVM

Tất cả issue của atomvm/AtomVM

Issue tương tự

Thêm issue về Networking

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.