I don't know how ejabberd likes to do things but l() is the lower level non-OTP way to do things and will immediately purge the old code and load the new code. Nothing else will happen, no magic. <br><br>On Friday, November 25, 2011, Daniel Dormont <<a href="mailto:dan@greywallsoftware.com">dan@greywallsoftware.com</a>> wrote:<br>
> This is a follow-up to my earlier question but the topic is a little<br>> different. Having put together a nice piece of code for handling the<br>> change in my gen_fsm's state record, I discovered to my chagrin that<br>
> when I loaded the new code (using l() at first and then using the<br>> "update" command that comes with ejabberd) it did not call the<br>> code_change callback; neither immediately nor before processing the<br>
> next message sent to that process. I admit that the details of things<br>> like proc_lib and sys are a little opaque to me, but I had understood<br>> that as long as the module implemented a standard OTP behavior, code<br>
> upgrades would "just work" in some sense. I suppose I was wrong :)<br>> This module is fairly self-contained, so I'm not too worried about<br>> having to synchronize other modules, notify supervisors or anything<br>
> like that. How do I proceed from here?<br>><br>> thanks,<br>> dan<br>><br>><br>> ---------- Forwarded message ----------<br>> From: Daniel Dormont <<a href="mailto:dan@greywallsoftware.com">dan@greywallsoftware.com</a>><br>
> Date: Mon, Nov 21, 2011 at 10:51 AM<br>> Subject: code_change for gen_fsm: how to actually handle a state change<br>> To: erlang-questions <<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>><br>
><br>><br>> Hello all,<br>><br>> I have a gen_fsm module and would like to take advantage of hot code<br>> deploy. The module uses a record (called "state") and the new version<br>> of the module includes some new fields in the record. What is a nice<br>
> clean way to code the my_module:code_change function to deal with<br>> this? Are there any good examples out there on the web?<br>><br>> Note: for my purposes it would be sufficient to detect that the state<br>
> record is out of date, and terminate cleanly. BUT the correct<br>> functionality of the terminate/3 function in my module depends on the<br>> state data, and I would need it to complete cleanly and not crash in<br>
> this instance because there are other processes that depend on this<br>> one and need to be notified properly of its exit. The issue is that<br>> the state itself contains the data of which processes those are.<br>
><br>> What's the best approach here?<br>><br>> thanks,<br>> Dan<br>> _______________________________________________<br>> erlang-questions mailing list<br>> <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
> <a href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a><br>>