You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2018/06/22 16:06:49 UTC
[couchdb] branch fix-erlang-21-eunit-failures updated: A better fix
for handling node local 413 responses
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch fix-erlang-21-eunit-failures
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/fix-erlang-21-eunit-failures by this push:
new 4ad5b32 A better fix for handling node local 413 responses
4ad5b32 is described below
commit 4ad5b326d7de1b53e7da5798ccb33863ba6bbace
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Fri Jun 22 11:12:40 2018 -0400
A better fix for handling node local 413 responses
During 21.0 testing, the hack to read extra data from the socket to give the
client a better chance of detecting a 413 response ended up failing. Either
process scheduling or IO scheduling was different enough that the test started
failing fairly consistently.
Apply a better fix that's more in-line with the intent -- after responding to
the client with a 413, read a limited amount of data off the socket (1MB).
Limit the maximum time spent doing it to less than 1 second.
Issue #1396
---
src/couch/src/couch_httpd.erl | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/couch/src/couch_httpd.erl b/src/couch/src/couch_httpd.erl
index b4f01af..1ec7096 100644
--- a/src/couch/src/couch_httpd.erl
+++ b/src/couch/src/couch_httpd.erl
@@ -40,6 +40,8 @@
-define(HANDLER_NAME_IN_MODULE_POS, 6).
+-define(MAX_DRAIN_BYTES, 1048576).
+-define(MAX_DRAIN_TIME_MSEC, 1000).
start_link() ->
start_link(http).
@@ -1181,10 +1183,9 @@ respond_(#httpd{mochi_req = MochiReq}, 413, Headers, Args, Type) ->
% just increases the chances of 413 being detected correctly by the client
% (rather than getting a brutal TCP reset).
erlang:put(mochiweb_request_force_close, true),
- Socket = MochiReq:get(socket),
- mochiweb_socket:recv(Socket, 0, 0),
Result = MochiReq:Type({413, Headers, Args}),
- mochiweb_socket:recv(Socket, 0, 0),
+ Socket = MochiReq:get(socket),
+ mochiweb_socket:recv(Socket, ?MAX_DRAIN_BYTES, ?MAX_DRAIN_TIME_MSEC),
Result;
respond_(#httpd{mochi_req = MochiReq}, Code, Headers, Args, Type) ->
MochiReq:Type({Code, Headers, Args}).