0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00

Don't crash on Transport:controlling_process return in the acceptor.

Crashes can happen if we close the connection too fast, leading to
controlling_process returning {error, closed} instead of ok. This can
happen when we receive bad requests, reply with 404 Not Found and more.
Simply do not match the return value of controlling_process to avoid this.
This commit is contained in:
Loïc Hoguin 2011-03-17 22:22:09 +01:00
parent 0069e2465d
commit a77b906b9f

View file

@ -35,7 +35,7 @@ acceptor(LSocket, Transport, Protocol, Opts) ->
{ok, CSocket} -> {ok, CSocket} ->
{ok, Pid} = supervisor:start_child(cowboy_protocols_sup, {ok, Pid} = supervisor:start_child(cowboy_protocols_sup,
[CSocket, Transport, Protocol, Opts]), [CSocket, Transport, Protocol, Opts]),
ok = Transport:controlling_process(CSocket, Pid); Transport:controlling_process(CSocket, Pid);
{error, _Reason} -> {error, _Reason} ->
%% @todo Probably do something here. If the socket was closed, %% @todo Probably do something here. If the socket was closed,
%% we may want to try and listen again on the port? %% we may want to try and listen again on the port?