diff options
author | Robert Newson <robert.newson@cloudant.com> | 2012-02-22 17:12:22 +0000 |
---|---|---|
committer | Robert Newson <robert.newson@cloudant.com> | 2012-02-22 17:13:21 +0000 |
commit | 986c86bf4355ea2b772e141d008efd1894b7df30 (patch) | |
tree | 22546c27d8ccacd0775266423217ef91c06013c6 /apps/couch/src | |
parent | f5913f7f4d59e8aee16468325497caf33894d3a3 (diff) | |
parent | db23528537fed7b9b0e85d3f3617f560cb52d630 (diff) |
Merge 0.4.x
Diffstat (limited to 'apps/couch/src')
-rw-r--r-- | apps/couch/src/couch_rep_writer.erl | 19 |
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. |