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/18 06:34:25 UTC

[GitHub] tonysun83 commented on a change in pull request #1067: Fix mango native proc crash

tonysun83 commented on a change in pull request #1067: Fix mango native proc crash
URL: https://github.com/apache/couchdb/pull/1067#discussion_r157408489
 
 

 ##########
 File path: src/mango/src/mango_native_proc.erl
 ##########
 @@ -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)
 
 Review comment:
   So iiuc, when the spawned process starts garbage collection, it'll exit with ```gc_start`` which would then cause our mango_native_proc to exit with an ```{invalid_cast, gc_start}```

----------------------------------------------------------------
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