Skip to content

Commit

Permalink
Fixing OS process leaks in list calls.
Browse files Browse the repository at this point in the history
Backporting 831502.



git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/0.10.x@831592 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
davisp committed Oct 31, 2009
1 parent 9a12b86 commit 4405bb0
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/couchdb/couch_httpd_show.erl
Expand Up @@ -301,14 +301,14 @@ output_reduce_list(#httpd{mochi_req=MReq, user_ctx=UserCtx}=Req, Lang, ListSrc,
end_docid = EndDocId,
group_level = GroupLevel
} = QueryArgs,
% get the os process here
% pass it into the view fold with closures
{ok, QueryServer} = couch_query_servers:start_view_list(Lang, ListSrc),
Headers = MReq:get(headers),
Hlist = mochiweb_headers:to_list(Headers),
Accept = proplists:get_value('Accept', Hlist),
CurrentEtag = couch_httpd_view:view_group_etag(Group, Db, {Lang, ListSrc, Accept, UserCtx}),
couch_httpd:etag_respond(Req, CurrentEtag, fun() ->
% get the os process here
% pass it into the view fold with closures
{ok, QueryServer} = couch_query_servers:start_view_list(Lang, ListSrc),
StartListRespFun = make_reduce_start_resp_fun(QueryServer, Req, Db, CurrentEtag),
SendListRowFun = make_reduce_send_row_fun(QueryServer, Db),

Expand All @@ -334,15 +334,15 @@ output_reduce_list(#httpd{mochi_req=MReq, user_ctx=UserCtx}=Req, Lang, ListSrc,
end_docid = EndDocId,
group_level = GroupLevel
} = QueryArgs,
% get the os process here
% pass it into the view fold with closures
{ok, QueryServer} = couch_query_servers:start_view_list(Lang, ListSrc),
Headers = MReq:get(headers),
Hlist = mochiweb_headers:to_list(Headers),
Accept = proplists:get_value('Accept', Hlist),
CurrentEtag = couch_httpd_view:view_group_etag(Group, Db, {Lang, ListSrc, Accept, UserCtx, Keys}),

couch_httpd:etag_respond(Req, CurrentEtag, fun() ->
% get the os process here
% pass it into the view fold with closures
{ok, QueryServer} = couch_query_servers:start_view_list(Lang, ListSrc),
StartListRespFun = make_reduce_start_resp_fun(QueryServer, Req, Db, CurrentEtag),
SendListRowFun = make_reduce_send_row_fun(QueryServer, Db),

Expand Down Expand Up @@ -381,6 +381,7 @@ finish_list(Req, QueryServer, Etag, FoldResult, StartFun, TotalRows) ->
[<<"end">>, Chunks] = couch_query_servers:render_list_tail(QueryServer),
send_non_empty_chunk(Resp, ?b2l(?l2b(Chunks)))
end,
couch_query_servers:stop_doc_map(QueryServer),
send_chunk(Resp, []).


Expand Down

0 comments on commit 4405bb0

Please sign in to comment.