You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2020/02/27 20:05:56 UTC
[couchdb] branch fix-mem3-sync-event-listener-test created (now
767b110)
This is an automated email from the ASF dual-hosted git repository.
davisp pushed a change to branch fix-mem3-sync-event-listener-test
in repository https://gitbox.apache.org/repos/asf/couchdb.git.
at 767b110 Fix mem3_sync_event_listener test
This branch includes the following new commits:
new 767b110 Fix mem3_sync_event_listener test
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[couchdb] 01/01: Fix mem3_sync_event_listener test
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davisp pushed a commit to branch fix-mem3-sync-event-listener-test
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 767b1109257770bcf30c0f5fc8c8a1926e12e96e
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Thu Feb 27 14:02:51 2020 -0600
Fix mem3_sync_event_listener test
There's a race between the meck:wait call in setup and killing the
config_event process. Its possible that we could kill and restart the
config_event process after meck:wait returns, but before
gen_event:add_sup_handler is called. More likely, we could end up
killing the config_event gen_event process before its fully handled the
add_sup_handler message and linked the notifier pid.
This avoids the race by waiting for config_event to return that it has
processed the add_sup_handler message instead of relying on meck:wait
for the subscription call.
---
src/mem3/src/mem3_sync_event_listener.erl | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/mem3/src/mem3_sync_event_listener.erl b/src/mem3/src/mem3_sync_event_listener.erl
index b6fbe32..cad3422 100644
--- a/src/mem3/src/mem3_sync_event_listener.erl
+++ b/src/mem3/src/mem3_sync_event_listener.erl
@@ -236,7 +236,7 @@ teardown_all(_) ->
setup() ->
{ok, Pid} = ?MODULE:start_link(),
erlang:unlink(Pid),
- meck:wait(config_notifier, subscribe, '_', 1000),
+ wait_config_subscribed(Pid),
Pid.
teardown(Pid) ->
@@ -338,4 +338,16 @@ wait_state(Pid, Field, Val) when is_pid(Pid), is_integer(Field) ->
end,
test_util:wait(WaitFun).
+
+wait_config_subscribed(Pid) ->
+ WaitFun = fun() ->
+ Handlers = gen_event:which_handlers(config_event),
+ Pids = [Id || {config_notifier, Id} <- Handlers],
+ case lists:member(Pid, Pids) of
+ true -> true;
+ false -> wait
+ end
+ end,
+ test_util:wait(WaitFun).
+
-endif.