You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2017/12/20 20:44:37 UTC

[GitHub] eiri closed pull request #1067: Fix mango native proc crash

eiri closed pull request #1067: Fix mango native proc crash
URL: https://github.com/apache/couchdb/pull/1067
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/mango/src/mango_idx_text.erl b/src/mango/src/mango_idx_text.erl
index 369e2cd086..29b4441a10 100644
--- a/src/mango/src/mango_idx_text.erl
+++ b/src/mango/src/mango_idx_text.erl
@@ -330,7 +330,7 @@ indexable_fields(Fields, {op_not, {ExistsQuery, Arg}}) when is_tuple(Arg) ->
     Fields0 = indexable_fields(Fields, ExistsQuery),
     indexable_fields(Fields0, Arg);
 % forces "$exists" : false to use _all_docs
-indexable_fields(Fields, {op_not, {ExistsQuery, false}}) ->
+indexable_fields(_, {op_not, {_, false}}) ->
     [];
 
 indexable_fields(Fields, {op_insert, Arg}) when is_binary(Arg) ->
diff --git a/src/mango/src/mango_native_proc.erl b/src/mango/src/mango_native_proc.erl
index 61d79b7ecc..7a34201939 100644
--- a/src/mango/src/mango_native_proc.erl
+++ b/src/mango/src/mango_native_proc.erl
@@ -113,6 +113,9 @@ handle_cast(garbage_collect, St) ->
     erlang:garbage_collect(),
     {noreply, St};
 
+handle_cast(stop, St) ->
+    {stop, normal, St};
+
 handle_cast(Msg, St) ->
     {stop, {invalid_cast, Msg}, St}.
 
@@ -363,4 +366,35 @@ validate_index_info(IndexInfo) ->
             [invalid_index | Results0]
         end
     end, [], IdxTypes),
-    lists:member(valid_index, Results).
\ No newline at end of file
+    lists:member(valid_index, Results).
+
+
+-ifdef(TEST).
+
+-include_lib("eunit/include/eunit.hrl").
+
+handle_garbage_collect_cast_test() ->
+    Pid = self(),
+    {_, TracerRef} = spawn_monitor(fun() ->
+        erlang:trace(Pid, true, [garbage_collection]),
+        receive {trace, Pid, gc_start, _} ->
+            erlang:trace(Pid, false, [garbage_collection]),
+            exit(gc_start)
+        end
+    end),
+    erlang:yield(),
+    ?assertEqual({noreply, []}, handle_cast(garbage_collect, [])),
+    receive
+        {'DOWN', TracerRef, _, _, Msg} -> ?assertEqual(gc_start, Msg)
+    after 1000 ->
+        erlang:error({assertion_failed, [{module, ?MODULE}, {line, ?LINE},
+            {expected, gc_start}, {reason, timeout}]})
+    end.
+
+handle_stop_cast_test() ->
+    ?assertEqual({stop, normal, []}, handle_cast(stop, [])).
+
+handle_invalid_cast_test() ->
+    ?assertEqual({stop, {invalid_cast, random}, []}, handle_cast(random, [])).
+
+-endif.


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services