couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [16/50] mochiweb commit: updated refs/heads/1843-feature-bigcouch to 432c949
Date Thu, 17 Apr 2014 18:16:44 GMT
workaround to fix edoc build


Project: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/commit/27410548
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/tree/27410548
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/diff/27410548

Branch: refs/heads/1843-feature-bigcouch
Commit: 27410548e5f8e30b6c3522be0b5a5f84fb3365c4
Parents: b57014d
Author: Bob Ippolito <bob@redivi.com>
Authored: Thu Aug 1 13:27:10 2013 -0700
Committer: Bob Ippolito <bob@redivi.com>
Committed: Thu Aug 1 13:27:10 2013 -0700

----------------------------------------------------------------------
 src/mochiweb_http.erl | 44 ++++++++++++++++++++++++--------------------
 1 file changed, 24 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/blob/27410548/src/mochiweb_http.erl
----------------------------------------------------------------------
diff --git a/src/mochiweb_http.erl b/src/mochiweb_http.erl
index 931ecd0..8c814cb 100644
--- a/src/mochiweb_http.erl
+++ b/src/mochiweb_http.erl
@@ -17,6 +17,12 @@
 -define(DEFAULTS, [{name, ?MODULE},
                    {port, 8888}]).
 
+-ifdef(gen_tcp_r15b_workaround).
+r15b_workaround() -> true.
+-else.
+r15b_workaround() -> false.
+-endif.
+
 parse_options(Options) ->
     {loop, HttpLoop} = proplists:lookup(loop, Options),
     Loop = {?MODULE, loop, [HttpLoop]},
@@ -50,16 +56,6 @@ loop(Socket, Body) ->
     ok = mochiweb_socket:setopts(Socket, [{packet, http}]),
     request(Socket, Body).
 
--ifdef(gen_tcp_r15b_workaround).
--define(R15B_GEN_TCP_FIX, {tcp_error,_,emsgsize} ->
-                 % R15B02 returns this then closes the socket, so close and exit
-                 mochiweb_socket:close(Socket),
-                 exit(normal);
-       ).
--else.
--define(R15B_GEN_TCP_FIX,).
--endif.
-
 request(Socket, Body) ->
     ok = mochiweb_socket:setopts(Socket, [{active, once}]),
     receive
@@ -76,9 +72,8 @@ request(Socket, Body) ->
         {ssl_closed, _} ->
             mochiweb_socket:close(Socket),
             exit(normal);
-        ?R15B_GEN_TCP_FIX
-        _Other ->
-            handle_invalid_request(Socket)
+        Other ->
+            handle_invalid_msg_request(Other, Socket)
     after ?REQUEST_RECV_TIMEOUT ->
         mochiweb_socket:close(Socket),
         exit(normal)
@@ -106,9 +101,8 @@ headers(Socket, Request, Headers, Body, HeaderCount) ->
         {tcp_closed, _} ->
             mochiweb_socket:close(Socket),
             exit(normal);
-        ?R15B_GEN_TCP_FIX
-        _Other ->
-            handle_invalid_request(Socket, Request, Headers)
+        Other ->
+            handle_invalid_msg_request(Other, Socket, Request, Headers)
     after ?HEADERS_RECV_TIMEOUT ->
         mochiweb_socket:close(Socket),
         exit(normal)
@@ -121,10 +115,20 @@ call_body({M, F}, Req) ->
 call_body(Body, Req) ->
     Body(Req).
 
--spec handle_invalid_request(term()) -> no_return().
-handle_invalid_request(Socket) ->
-    handle_invalid_request(Socket, {'GET', {abs_path, "/"}, {0,9}}, []),
-    exit(normal).
+-spec handle_invalid_msg_request(term(), term()) -> no_return().
+handle_invalid_msg_request(Msg, Socket) ->
+    handle_invalid_msg_request(Msg, Socket, {'GET', {abs_path, "/"}, {0,9}}, []).
+
+-spec handle_invalid_msg_request(term(), term(), term(), term()) -> no_return().
+handle_invalid_msg_request(Msg, Socket, Request, RevHeaders) ->
+    case {Msg, r15b_workaround()} of
+        {{tcp_error,_,emsgsize}, true} ->
+            %% R15B02 returns this then closes the socket, so close and exit
+            mochiweb_socket:close(Socket),
+            exit(normal);
+        _ ->
+            handle_invalid_request(Socket, Request, RevHeaders)
+    end.
 
 -spec handle_invalid_request(term(), term(), term()) -> no_return().
 handle_invalid_request(Socket, Request, RevHeaders) ->


Mime
View raw message