Do not log client disconnects as errors
In the future it would be nice to collect metrics of these, but
practically speaking we already have them in the HAProxy logs.
BugzID: 14090
Conflicts:
src/chttpd.erl
Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/b1698e9d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/b1698e9d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/b1698e9d
Branch: refs/heads/import
Commit: b1698e9d20cf82c73acfccdd6fc5814ff7887706
Parents: c5e3ac9
Author: Adam Kocoloski <[email protected]>
Authored: Tue Jan 8 15:35:18 2013 -0500
Committer: Robert Newson <[email protected]>
Committed: Tue Mar 5 20:18:21 2013 -0600
----------------------------------------------------------------------
src/chttpd.erl | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/b1698e9d/src/chttpd.erl
----------------------------------------------------------------------
diff --git a/src/chttpd.erl b/src/chttpd.erl
index a68836a..f1526fc 100644
--- a/src/chttpd.erl
+++ b/src/chttpd.erl
@@ -234,9 +234,17 @@ handle_request(MochiReq) ->
send_error(HttpReq, database_does_not_exist);
Tag:Error ->
Stack = erlang:get_stacktrace(),
- twig:log(error, "~p ~p ~p ~p", [?MODULE, Tag, Error,
- json_stack(Error, nill, Stack)]),
- send_error(HttpReq, {Error, nil, Stack})
+ % TODO improve logging and metrics collection for client
disconnects
+ case {Tag, Error, Stack} of
+ {exit, normal, [{mochiweb_request, send, _, _} | _]} ->
+ exit(normal); % Client disconnect (R15+)
+ {exit, normal, [{mochiweb_request, send, _} | _]} ->
+ exit(normal); % Client disconnect (R14)
+ _Else ->
+ JsonStack = json_stack({Error, nil, Stack}),
+ twig:log(error, "req_err ~p:~p ~p", [Tag, Error,
JsonStack]),
+ send_error(HttpReq, {Error, nil, Stack})
+ end
end,
RequestTime = timer:now_diff(os:timestamp(), Begin)/1000,