diff options
author | juhlig <[email protected]> | 2019-06-04 15:13:31 +0200 |
---|---|---|
committer | juhlig <[email protected]> | 2019-06-04 15:13:31 +0200 |
commit | b1169f6d3b5688c655be54756a480cceadded223 (patch) | |
tree | 6a9f6c39aa77a14a538bc38dcce6f0365f1c8e97 /test/notify_and_wait_protocol.erl | |
parent | 0523081e39e9825f5efa69a0dab5deefbb075cce (diff) | |
download | ranch-b1169f6d3b5688c655be54756a480cceadded223.tar.gz ranch-b1169f6d3b5688c655be54756a480cceadded223.tar.bz2 ranch-b1169f6d3b5688c655be54756a480cceadded223.zip |
Fix Windows timing issues
Diffstat (limited to 'test/notify_and_wait_protocol.erl')
-rw-r--r-- | test/notify_and_wait_protocol.erl | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/test/notify_and_wait_protocol.erl b/test/notify_and_wait_protocol.erl index 37d0f42..26f6907 100644 --- a/test/notify_and_wait_protocol.erl +++ b/test/notify_and_wait_protocol.erl @@ -2,13 +2,15 @@ -behaviour(ranch_protocol). -export([start_link/3]). --export([init/3]). +-export([init/4]). -start_link(_, _, Opts = #{msg := Msg, pid := TestPid}) -> - Timeout = maps:get(timeout, Opts, 2500), - Pid = spawn_link(?MODULE, init, [Msg, TestPid, Timeout]), +start_link(_, _, Opts = #{pid := TestPid}) -> + Msg = maps:get(msg, Opts, connected), + TerminateMsg = maps:get(terminate_msg, Opts, stop), + Timeout = maps:get(timeout, Opts, infinity), + Pid = spawn_link(?MODULE, init, [Msg, TestPid, TerminateMsg, Timeout]), {ok, Pid}. -init(Msg, Pid, Timeout) -> - Pid ! Msg, - receive after Timeout -> ok end. +init(Msg, Pid, TerminateMsg, Timeout) -> + Pid ! {self(), Msg}, + receive TerminateMsg -> ok after Timeout -> ok end. |