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:
parent
0069e2465d
commit
a77b906b9f
1 changed files with 1 additions and 1 deletions
|
@ -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?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue