summaryrefslogtreecommitdiff
path: root/apps/couch/src
diff options
context:
space:
mode:
authorRobert Newson <robert.newson@cloudant.com>2012-02-22 17:12:22 +0000
committerRobert Newson <robert.newson@cloudant.com>2012-02-22 17:13:21 +0000
commit986c86bf4355ea2b772e141d008efd1894b7df30 (patch)
tree22546c27d8ccacd0775266423217ef91c06013c6 /apps/couch/src
parentf5913f7f4d59e8aee16468325497caf33894d3a3 (diff)
parentdb23528537fed7b9b0e85d3f3617f560cb52d630 (diff)
Merge 0.4.x
Diffstat (limited to 'apps/couch/src')
-rw-r--r--apps/couch/src/couch_rep_writer.erl19
1 files changed, 12 insertions, 7 deletions
diff --git a/apps/couch/src/couch_rep_writer.erl b/apps/couch/src/couch_rep_writer.erl
index 40323925..cea4408e 100644
--- a/apps/couch/src/couch_rep_writer.erl
+++ b/apps/couch/src/couch_rep_writer.erl
@@ -126,13 +126,18 @@ write_multi_part_doc(#http_db{headers=Headers} = Db, #doc{atts=Atts} = Doc) ->
{"Content-Length", Len} | Headers
]
},
- Result = case couch_rep_httpc:request(Request) of
- {[{<<"error">>, Error}, {<<"reason">>, Reason}]} ->
- {Pos, [RevId | _]} = Doc#doc.revs,
- ErrId = couch_util:to_existing_atom(Error),
- [{Doc#doc.id, couch_doc:rev_to_str({Pos, RevId})}, {ErrId, Reason}];
- _ ->
- []
+ Conn = couch_rep_httpc:spawn_link_worker_process(Request),
+ Result = try
+ case couch_rep_httpc:request(Request#http_db{conn=Conn}) of
+ {[{<<"error">>, Error}, {<<"reason">>, Reason}]} ->
+ {Pos, [RevId | _]} = Doc#doc.revs,
+ ErrId = couch_util:to_existing_atom(Error),
+ [{Doc#doc.id, couch_doc:rev_to_str({Pos, RevId})}, {ErrId, Reason}];
+ _ ->
+ []
+ end
+ after
+ ibrowse:stop_worker_process(Conn)
end,
StreamerPid ! stop,
Result.