diff options
author | Raimo Niskanen <[email protected]> | 2016-10-14 10:08:49 +0200 |
---|---|---|
committer | Raimo Niskanen <[email protected]> | 2016-10-14 10:08:49 +0200 |
commit | 5e2d802e29f0a8f81de297f9a3e3922f2d6cd6c0 (patch) | |
tree | 66706f557ab80be34b7a4919a5ba8bc34d5dcfaf /lib/stdlib/src/gen_statem.erl | |
parent | f4de3f5887be010db178a178e1f20027f3e5d22b (diff) | |
download | otp-5e2d802e29f0a8f81de297f9a3e3922f2d6cd6c0.tar.gz otp-5e2d802e29f0a8f81de297f9a3e3922f2d6cd6c0.tar.bz2 otp-5e2d802e29f0a8f81de297f9a3e3922f2d6cd6c0.zip |
Fix race condition in cancel_timer/1
Diffstat (limited to 'lib/stdlib/src/gen_statem.erl')
-rw-r--r-- | lib/stdlib/src/gen_statem.erl | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/stdlib/src/gen_statem.erl b/lib/stdlib/src/gen_statem.erl index 5c750cb93d..17d1ebecec 100644 --- a/lib/stdlib/src/gen_statem.erl +++ b/lib/stdlib/src/gen_statem.erl @@ -1609,13 +1609,14 @@ cancel_timer(undefined) -> ok; cancel_timer(TRef) -> case erlang:cancel_timer(TRef) of - TimeLeft when is_integer(TimeLeft) -> - ok; false -> + %% We have to assume that TRef is the ref of a running timer + %% and if so the timer has expired + %% hence we must wait for the timeout message receive {timeout,TRef,_} -> ok - after 0 -> - ok - end + end; + _TimeLeft -> + ok end. |