couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bbast...@apache.org
Subject [1/3] couch-mrview commit: updated refs/heads/master to f897fdc
Date Thu, 16 Mar 2017 17:19:27 GMT
Repository: couchdb-couch-mrview
Updated Branches:
  refs/heads/master 49533ef9d -> f897fdc2c


Fix undef error on empty list function response

Prior to this commit, if a list function did not return any data or
returned an error, it would return a #lacc{} record from list_cb/2
rather than a valid #mochiweb_response{} record. This would cause chttpd
to crash. This commit fixes this bug by always returning a valid
record.


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/56616fad
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/tree/56616fad
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/diff/56616fad

Branch: refs/heads/master
Commit: 56616fad9b0621b6606e4b521a2ec4b8342877aa
Parents: e1d13a9
Author: Benjamin Bastian <benjamin.bastian@gmail.com>
Authored: Thu Mar 9 18:20:25 2017 -0800
Committer: Benjamin Bastian <benjamin.bastian@gmail.com>
Committed: Thu Mar 9 18:20:25 2017 -0800

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


http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/56616fad/src/couch_mrview_show.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview_show.erl b/src/couch_mrview_show.erl
index 52e07a7..f79ad62 100644
--- a/src/couch_mrview_show.erl
+++ b/src/couch_mrview_show.erl
@@ -284,26 +284,24 @@ send_list_row(Row, #lacc{qserver = {Proc, _}, req = Req, resp = Resp}
= Acc) ->
         Acc2 = send_non_empty_chunk(Acc, Chunk),
         {ok, Acc2};
     [<<"end">>, Chunk, Headers] ->
-        Acc2 = send_non_empty_chunk(fixup_headers(Headers, Acc), Chunk),
-        #lacc{resp = Resp2} = Acc2,
-        last_chunk(Req, Resp2),
-        {stop, Acc2};
+        #lacc{resp = Resp2} = send_non_empty_chunk(fixup_headers(Headers, Acc), Chunk),
+        {ok, Resp3} = last_chunk(Req, Resp2),
+        {stop, Resp3};
     [<<"end">>, Chunk] ->
-        Acc2 = send_non_empty_chunk(Acc, Chunk),
-        #lacc{resp = Resp2} = Acc2,
-        last_chunk(Req, Resp2),
-        {stop, Acc2}
+        #lacc{resp = Resp2} = send_non_empty_chunk(Acc, Chunk),
+        {ok, Resp3} = last_chunk(Req, Resp2),
+        {stop, Resp3}
     catch Error ->
-        case Resp of
+        {ok, Resp2} = case Resp of
             undefined ->
                 {Code, _, _} = chttpd:error_info(Error),
                 #lacc{req=Req, headers=Headers} = Acc,
-                {ok, Resp2} = chttpd:start_chunked_response(Req, Code, Headers),
-                Acc2 = Acc#lacc{resp=Resp2, code=Code};
-            _ -> Resp2 = Resp, Acc2 = Acc
+                chttpd:start_chunked_response(Req, Code, Headers);
+            _ ->
+                {ok, Resp}
         end,
-        chttpd:send_chunked_error(Resp2, Error),
-        {stop, Acc2}
+        {ok, Resp3} = chttpd:send_chunked_error(Resp2, Error),
+        {stop, Resp3}
     end.
 
 send_non_empty_chunk(Acc, []) ->


Mime
View raw message