[erlang-questions] timer, bug !?

Erik Søe Sørensen eriksoe@REDACTED
Sun Aug 5 21:00:11 CEST 2012


Have you considered that by the time you call cancel, the timeout message
may already be on its way to your process?
One solution is to make your timeout messages versioned, and check the
version at reception time.
Another is to clear the inbox of pending timeout messages just after cancel
returns.
Den 05/08/2012 06.33 skrev "Dmitry Kolesnikov" <dmkolesnikov@REDACTED>:

> Hello,
>
> I am getting a wired eunit test failure. I am sorry,  the code is
> complicated and it cannot be share here. In nutshell, I do have a
> gen_server that uses timer:send_after(...) to send timeout message to
> itself, often it uses timeout equals to 0. If some other message arrives
> before timeout, then timer is cancelled by timer:cancel(...)
>
> Sometimes, with probability 1/5 - 1/6 timeout message is duplicated, see
> log below. However, if I switch to erlang:send_after and
> erlang:cancel_timer the issue disappears. Doe anyone seen a similar effect?
> Why timer duplicates message?
>
>
> 07:21:51.683 [error] make timer: <0.183.0> T=0
> 07:21:51.684 [error] timeout <0.183.0>
> ...
> 07:21:51.693 [error] make timer: <0.183.0> T=0
> ...
> 07:21:51.695 [error] cancel timer: <0.183.0>
> 07:21:51.696 [error] make timer: <0.183.0> T = 0
> 07:21:51.696 [error] timeout <0.183.0>
> 07:21:51.697 [error] make timer: <0.183.0> T = 0
> 07:21:51.698 [error] cancel timer: <0.183.0>
> 07:21:51.699 [error] make timer: <0.183.0> T = 0
> 07:21:51.699 [error] timeout <0.183.0>
> 07:21:51.700 [error] make timer: <0.183.0> T = 0
> 07:21:51.701 [error] timeout <0.183.0>
> 07:21:51.701 [error] timeout <0.183.0>
>
> Best Regards, Dmitry
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120805/3f51648b/attachment.htm>


More information about the erlang-questions mailing list