summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_rep_att.erl
diff options
context:
space:
mode:
authorJan Lehnardt <jan@apache.org>2010-02-28 02:41:52 +0000
committerJan Lehnardt <jan@apache.org>2010-02-28 02:41:52 +0000
commit1be99a1ef26c3d9233483cd7d0e0ff3f96ca8514 (patch)
treea4268dc90249b6965658cf9def9cb1619c8115e4 /src/couchdb/couch_rep_att.erl
parent5a9f96cf2646a0c9db468cd7876e75cdb9fda742 (diff)
Merge branch 'show-deleted-docs' into trunk
* show-deleted-docs: treat deleted docs as nonexistant docs Revert "Avoid replication task crashes by imporoving timeout handling." git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@917098 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_rep_att.erl')
-rw-r--r--src/couchdb/couch_rep_att.erl28
1 files changed, 2 insertions, 26 deletions
diff --git a/src/couchdb/couch_rep_att.erl b/src/couchdb/couch_rep_att.erl
index ee4f0184..6b576a01 100644
--- a/src/couchdb/couch_rep_att.erl
+++ b/src/couchdb/couch_rep_att.erl
@@ -25,11 +25,7 @@ convert_stub(#att{data=stub, name=Name} = Attachment,
qs = [{rev, couch_doc:rev_to_str({Pos,RevId})}]
},
Ref = make_ref(),
- RcvFun = fun() ->
- Bin = attachment_receiver(Ref, Request),
- cleanup(),
- Bin
- end,
+ RcvFun = fun() -> attachment_receiver(Ref, Request) end,
Attachment#att{data=RcvFun}.
cleanup() ->
@@ -38,8 +34,6 @@ cleanup() ->
%% TODO maybe log, didn't expect to have data here
cleanup();
{ibrowse_async_response_end, _} ->
- cleanup();
- {ibrowse_async_headers, _, _, _} ->
cleanup()
after 0 ->
erase(),
@@ -49,27 +43,13 @@ cleanup() ->
% internal funs
attachment_receiver(Ref, Request) ->
- try case get(Ref) of
+ case get(Ref) of
undefined ->
{ReqId, ContentEncoding} = start_http_request(Request),
put(Ref, {ReqId, ContentEncoding}),
receive_data(Ref, ReqId, ContentEncoding);
{ReqId, ContentEncoding} ->
receive_data(Ref, ReqId, ContentEncoding)
- end
- catch
- throw:{attachment_request_failed, timeout} ->
- case {Request#http_db.retries, Request#http_db.pause} of
- {0, _} ->
- ?LOG_INFO("request for ~p failed", [Request#http_db.resource]),
- throw({attachment_request_failed, max_retries_reached});
- {N, Pause} when N > 0 ->
- ?LOG_INFO("request for ~p timed out, retrying in ~p seconds",
- [Request#http_db.resource, Pause/1000]),
- timer:sleep(Pause),
- cleanup(),
- attachment_receiver(Ref, Request#http_db{retries = N-1})
- end
end.
receive_data(Ref, ReqId, ContentEncoding) ->
@@ -91,8 +71,6 @@ receive_data(Ref, ReqId, ContentEncoding) ->
{ibrowse_async_response_end, ReqId} ->
?LOG_ERROR("streaming att. ended but more data requested ~p", [ReqId]),
throw({attachment_request_failed, premature_end})
- after 31000 ->
- throw({attachment_request_failed, timeout})
end.
start_http_request(Req) ->
@@ -106,8 +84,6 @@ start_http_request(Req) ->
{ok, ContentEncoding, NewReqId} ->
{NewReqId, ContentEncoding}
end
- after 10000 ->
- throw({attachment_request_failed, timeout})
end.
validate_headers(_Req, 200, Headers) ->