Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Exit with meaningful error messages instead of 'normal'. #74

Closed
wants to merge 1 commit into from

2 participants

@jdhood1

I'm not sure why you guys decided to exit with the atom 'normal' instead of the error that was returned from the call being made, but I'm having a tough time figuring out a socket error I'm getting from one of our clients without the information from gen_tcp:send(...). This change would really help that process. Thanks.

@etrepum
Owner

If you're handling billions of requests the TCP errors are guaranteed to happen often and not interesting. The error logging can take down your server actually. I won't accept this pull request but that shouldn't stop you from modifying your local copy as you see fit.

@etrepum etrepum closed this
@jdhood1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 19, 2012
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 11 deletions.
  1. +11 −11 src/mochiweb_request.erl
View
22 src/mochiweb_request.erl
@@ -96,7 +96,7 @@ get(peer) ->
{ok, {Addr, _Port}} ->
inet_parse:ntoa(Addr);
{error, enotconn} ->
- exit(normal)
+ exit({error, enotconn})
end;
get(path) ->
case erlang:get(?SAVE_PATH) of
@@ -140,8 +140,8 @@ send(Data) ->
case mochiweb_socket:send(Socket, Data) of
ok ->
ok;
- _ ->
- exit(normal)
+ Error ->
+ exit(Error)
end.
%% @spec recv(integer()) -> binary()
@@ -158,8 +158,8 @@ recv(Length, Timeout) ->
{ok, Data} ->
put(?SAVE_RECV, true),
Data;
- _ ->
- exit(normal)
+ Error ->
+ exit(Error)
end.
%% @spec body_length() -> undefined | chunked | unknown_transfer_encoding | integer()
@@ -503,8 +503,8 @@ read_chunk_length() ->
end,
{Hex, _Rest} = lists:splitwith(Splitter, binary_to_list(Header)),
mochihex:to_int(Hex);
- _ ->
- exit(normal)
+ Error ->
+ exit(Error)
end.
%% @spec read_chunk(integer()) -> Chunk::binary() | [Footer::binary()]
@@ -518,8 +518,8 @@ read_chunk(0) ->
Acc;
{ok, Footer} ->
F1(F1, [Footer | Acc]);
- _ ->
- exit(normal)
+ Error ->
+ exit(Error)
end
end,
Footers = F(F, []),
@@ -530,8 +530,8 @@ read_chunk(Length) ->
case mochiweb_socket:recv(Socket, 2 + Length, ?IDLE_TIMEOUT) of
{ok, <<Chunk:Length/binary, "\r\n">>} ->
Chunk;
- _ ->
- exit(normal)
+ Error ->
+ exit(Error)
end.
read_sub_chunks(Length, MaxChunkSize, Fun, FunState) when Length > MaxChunkSize ->
Something went wrong with that request. Please try again.