Skip to content

Commit

Permalink
Fix early close of socket in http_server
Browse files Browse the repository at this point in the history
The socket can close too fast for some clients, as exhibited on FreeBSD in recent failing CI tests:
https://github.com/atomvm/AtomVM/actions/runs/12977426531/job/36190827478#step:3:5747
Fixed by adding a 5000 ms delay before closing the socket.

Signed-off-by: Winford <winford@object.stream>
  • Loading branch information
UncleGrumpy committed Jan 26, 2025
1 parent 0d6a00e commit a359114
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libs/eavmlib/src/http_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ reply(StatusCode, ReplyBody, Conn) ->
StatusCode, ReplyBody, [<<"Content-Type: text/html\r\nConnection: close\r\n">>], Conn
),
Socket = proplists:get_value(socket, NewConn),
gen_tcp:close(Socket),
spawn_link(fun() ->
timer:sleep(5000),
gen_tcp:close(Socket)
end),
ClosedConn =
case proplists:get_value(closed, NewConn) of
undefined -> [{closed, true} | NewConn];
Expand Down

0 comments on commit a359114

Please sign in to comment.