Permalink
Browse files

only crash the acceptor loop on R15

  • Loading branch information...
benoitc committed May 3, 2013
1 parent 5fb9b55 commit 6b2124325d7b4fdfa627827c944732dab107ce30
Showing with 16 additions and 5 deletions.
  1. +3 −1 apps/couch_httpd/rebar.config
  2. +13 −4 apps/couch_httpd/src/couch_httpd_protocol.erl
@@ -4,7 +4,9 @@
{cover_enabled, true}.
{eunit_opts, [{report,{eunit_surefire,[{dir,"."}]}}]}.
{edoc_opts, [{preprocess, true}]}.
-{erl_opts, [warnings_as_errors, {parse_transform, lager_transform}]}.
+{erl_opts, [warnings_as_errors,
+ {platform_define, "(R14|R16)", 'gen_tcp_fix'},
+ {parse_transform, lager_transform}]}.
{deps, [
%% mochiweb module, http framework
@@ -24,6 +24,17 @@
{port, 8888}]).
+-ifndef(gen_tcp_fix).
+-define(R15B_GEN_TCP_FIX, {tcp_error,_,emsgsize} ->
+ % R15B02 returns this then closes the socket, so close and exit
+ Transport:close(Socket),
+ exit(normal);
+ ).
+-else.
+-define(R15B_GEN_TCP_FIX, ).
+-endif.
+
+
%% @doc Start a mochiweb process
-spec start_link(pid(), inet:socket(), module(), any()) -> {ok, pid()}.
start_link(ListenerPid, Socket, Transport, Opts) ->
@@ -63,10 +74,7 @@ request(#hstate{transport=Transport, socket=Socket}=State) ->
{ssl_closed, _} ->
Transport:close(Socket),
exit(normal);
- {tcp_error,_,emsgsize} ->
- % R15B02 returns this then closes the socket, so close and exit
- Transport:close(Socket),
- exit(normal);
+ ?R15B_GEN_TCP_FIX
_Other ->
handle_invalid_request(State)
after ?REQUEST_RECV_TIMEOUT ->
@@ -95,6 +103,7 @@ headers(#hstate{transport=Transport, socket=Socket, loop=Loop}=State, Request,
{tcp_closed, _} ->
Transport:close(Socket),
exit(normal);
+ ?R15B_GEN_TCP_FIX
_Other ->
handle_invalid_request(State, Request, Headers)
after ?HEADERS_RECV_TIMEOUT ->

0 comments on commit 6b21243

Please sign in to comment.