You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ch...@apache.org on 2014/03/28 19:45:28 UTC

[4/4] couch-mrview commit: updated refs/heads/1993-bigcouch-couch-mrview to 6cb1bd8

Allow couch_mrview_show to be more fully utilized by chttpd_show


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/commit/6cb1bd8e
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/tree/6cb1bd8e
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/diff/6cb1bd8e

Branch: refs/heads/1993-bigcouch-couch-mrview
Commit: 6cb1bd8eda740b322f0128ef8638e704c945c2b8
Parents: 3688736
Author: Russell Branca <ch...@gmail.com>
Authored: Thu Mar 27 14:45:10 2014 -0700
Committer: Russell Branca <ch...@gmail.com>
Committed: Thu Mar 27 14:45:10 2014 -0700

----------------------------------------------------------------------
 src/couch_mrview_show.erl | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/6cb1bd8e/src/couch_mrview_show.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview_show.erl b/src/couch_mrview_show.erl
index e08a688..4591c5d 100644
--- a/src/couch_mrview_show.erl
+++ b/src/couch_mrview_show.erl
@@ -15,7 +15,8 @@
 -export([
     handle_doc_show_req/3,
     handle_doc_update_req/3,
-    handle_view_list_req/3
+    handle_view_list_req/3,
+    list_cb/2
 ]).
 
 -include_lib("couch/include/couch_db.hrl").
@@ -182,7 +183,7 @@ handle_view_list_req(Req, _Db, _DDoc) ->
 
 
 handle_view_list(Req, Db, DDoc, LName, VDDoc, VName, Keys) ->
-    Args0 = couch_mrview_http:parse_qs(Req, Keys),
+    Args0 = couch_mrview_http:parse_params(Req, Keys),
     ETagFun = fun(BaseSig, Acc0) ->
         UserCtx = Req#httpd.user_ctx,
         Name = UserCtx#user_ctx.name,
@@ -240,7 +241,7 @@ list_cb(complete, Acc) ->
 
 start_list_resp(Head, Acc) ->
     #lacc{db=Db, req=Req, qserver=QServer, lname=LName} = Acc,
-    JsonReq = couch_httpd_external:json_req_obj(Req, Db),
+    JsonReq = json_req_obj(Req, Db),
 
     [<<"start">>,Chunk,JsonResp] = couch_query_servers:ddoc_proc_prompt(QServer,
         [<<"lists">>, LName], [Head, JsonReq]),
@@ -350,3 +351,13 @@ json_apply_field({Key, NewValue}, [], Acc) ->
     % end of list, add ours
     {[{Key, NewValue}|Acc]}.
 
+
+% This loads the db info if we have a fully loaded db record, but we might not
+% have the db locally on this node, so then load the info through fabric.
+json_req_obj(Req, #db{main_pid=Pid}=Db) when is_pid(Pid) ->
+    couch_httpd_external:json_req_obj(Req, Db);
+json_req_obj(Req, Db) ->
+    % use a separate process because we're already in a receive loop, and
+    % json_req_obj calls fabric:get_db_info()
+    spawn_monitor(fun() -> exit(chttpd_external:json_req_obj(Req, Db)) end),
+    receive {'DOWN', _, _, _, JsonReq} -> JsonReq end.