[erlang-questions] Programming Erlang code example bug?

Joel Fernandes agnel.joel@REDACTED
Sun Feb 1 13:24:56 CET 2009


This is just to discuss about a possible bug  in a code example of the
programming erlang book.
On pg 198, the wait_login_response function is called on connection to the
server, if you notice, the receive loop doesn't consider the possibility of
the user closing the client widget while the client process waits for a
response from the server. If this happens, the client receives a
widget-destroyed message from the widget but doesn't understand it because
the receive loop doeesn't have such a pattern, and so it matches it to the
pattern "Other" and then loops infintely till the login request to the
server succeeds.
On login success, the active function gets called and the client tries to
send received-messages to the widget process that just died, this results in
the client crashing..
A neater way of handling this would be to handle widget-destroyed message in
wait_login_response and gracefully terminate the client process during such
an event

Best wishes,
Joel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090201/4e8a7705/attachment.htm>


More information about the erlang-questions mailing list